Message ID | 1466532141-5430-1-git-send-email-tim.gardner@canonical.com |
---|---|
State | New |
Headers | show |
On Tue, Jun 21, 2016 at 12:02:21PM -0600, Tim Gardner wrote: > From: Frederic Barrat <fbarrat@linux.vnet.ibm.com> > > BugLink: http://bugs.launchpad.net/bugs/1594847 > > On bare-metal, when a device is attached to the cxl card, lsvpd shows > a location code such as (with cxlflash): > # lsvpd -l sg22 > ... > *YL U78CB.001.WZS0073-P1-C33-B0-T0-L0 > which makes it hard to easily identify the cxl adapter owning the > flash device, since in this example C33 refers to a P8 processor. > > lsvpd looks in the parent devices until it finds a location code, so the > device node for the vPHB ends up being used. > > By reusing the device node of the adapter for the vPHB, lsvpd shows: > # lsvpd -l sg16 > ... > *YL U78C9.001.WZS09XA-P1-C7-B1-T0-L3 > where C7 is the PCI slot of the cxl adapter. > > On powerVM, the vPHB was already using the adapter device node, so > there's no change there. > > Tested by cxlflash on bare-metal and powerVM. > > Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com> > Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com> > Acked-by: Ian Munsie <imunsie@au1.ibm.com> > Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> > (cherry picked from linux-next commit a430739009384ba2c4804f3a427334ff395433cd) > Signed-off-by: Tim Gardner <tim.gardner@canonical.com> > --- > drivers/misc/cxl/vphb.c | 21 ++++++++++----------- > 1 file changed, 10 insertions(+), 11 deletions(-) > > diff --git a/drivers/misc/cxl/vphb.c b/drivers/misc/cxl/vphb.c > index cdc7723..012b6aa 100644 > --- a/drivers/misc/cxl/vphb.c > +++ b/drivers/misc/cxl/vphb.c > @@ -208,20 +208,19 @@ static struct pci_controller_ops cxl_pci_controller_ops = > > int cxl_pci_vphb_add(struct cxl_afu *afu) > { > - struct pci_dev *phys_dev; > - struct pci_controller *phb, *phys_phb; > + struct pci_controller *phb; > struct device_node *vphb_dn; > struct device *parent; > > - if (cpu_has_feature(CPU_FTR_HVMODE)) { > - phys_dev = to_pci_dev(afu->adapter->dev.parent); > - phys_phb = pci_bus_to_host(phys_dev->bus); > - vphb_dn = phys_phb->dn; > - parent = &phys_dev->dev; > - } else { > - vphb_dn = afu->adapter->dev.parent->of_node; > - parent = afu->adapter->dev.parent; > - } > + /* The parent device is the adapter. Reuse the device node of > + * the adapter. > + * We don't seem to care what device node is used for the vPHB, > + * but tools such as lsvpd walk up the device parents looking > + * for a valid location code, so we might as well show devices > + * attached to the adapter as being located on that adapter. > + */ > + parent = afu->adapter->dev.parent; > + vphb_dn = parent->of_node; > > /* Alloc and setup PHB data structure */ > phb = pcibios_alloc_controller(vphb_dn); Looks to do what is claimed. Should be easily testable. Acked-by: Andy Whitcroft <apw@canonical.com> -apw
Applied to X. -Kamal
diff --git a/drivers/misc/cxl/vphb.c b/drivers/misc/cxl/vphb.c index cdc7723..012b6aa 100644 --- a/drivers/misc/cxl/vphb.c +++ b/drivers/misc/cxl/vphb.c @@ -208,20 +208,19 @@ static struct pci_controller_ops cxl_pci_controller_ops = int cxl_pci_vphb_add(struct cxl_afu *afu) { - struct pci_dev *phys_dev; - struct pci_controller *phb, *phys_phb; + struct pci_controller *phb; struct device_node *vphb_dn; struct device *parent; - if (cpu_has_feature(CPU_FTR_HVMODE)) { - phys_dev = to_pci_dev(afu->adapter->dev.parent); - phys_phb = pci_bus_to_host(phys_dev->bus); - vphb_dn = phys_phb->dn; - parent = &phys_dev->dev; - } else { - vphb_dn = afu->adapter->dev.parent->of_node; - parent = afu->adapter->dev.parent; - } + /* The parent device is the adapter. Reuse the device node of + * the adapter. + * We don't seem to care what device node is used for the vPHB, + * but tools such as lsvpd walk up the device parents looking + * for a valid location code, so we might as well show devices + * attached to the adapter as being located on that adapter. + */ + parent = afu->adapter->dev.parent; + vphb_dn = parent->of_node; /* Alloc and setup PHB data structure */ phb = pcibios_alloc_controller(vphb_dn);