diff mbox series

[05/16] core/pci: Fix scan of devices for opencapi slots

Message ID 20190909123151.21944-6-fbarrat@linux.ibm.com
State Superseded
Headers show
Series opencapi: enable card reset and link retraining | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (470ffb5f29d741c3bed600f7bb7bf0cbb270e05a)
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present

Commit Message

Frederic Barrat Sept. 9, 2019, 12:31 p.m. UTC
Opencapi devices are found directly under the PHB and the PHB slot
doesn't have an associated PCI device (root complex). So when scanning
a PHB, devices are added directly under the PHB, like it's done at
boot time.

Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
---
 core/pci-opal.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

Comments

Christophe Lombard Sept. 17, 2019, 9:07 a.m. UTC | #1
On 09/09/2019 14:31, Frederic Barrat wrote:
> Opencapi devices are found directly under the PHB and the PHB slot
> doesn't have an associated PCI device (root complex). So when scanning
> a PHB, devices are added directly under the PHB, like it's done at
> boot time.
> 
> Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
> ---
>   core/pci-opal.c | 20 +++++++++++++++-----
>   1 file changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/core/pci-opal.c b/core/pci-opal.c
> index 6c070030..23aac84e 100644
> --- a/core/pci-opal.c
> +++ b/core/pci-opal.c


Reviewed-by: Christophe Lombard <clombard@linux.vnet.ibm.com>
diff mbox series

Patch

diff --git a/core/pci-opal.c b/core/pci-opal.c
index 6c070030..23aac84e 100644
--- a/core/pci-opal.c
+++ b/core/pci-opal.c
@@ -664,10 +664,17 @@  static void rescan_slot_devices(struct pci_slot *slot)
 	struct pci_device *pd = slot->pd;
 
 	slot->ops.prepare_link_change(slot, true);
-	pci_scan_bus(phb, pd->secondary_bus,
-		     pd->subordinate_bus, &pd->children, pd, true);
-	pci_add_device_nodes(phb, &pd->children, pd->dn,
-			     &phb->lstate, 0);
+	if (phb->phb_type != phb_type_npu_v2_opencapi) {
+		pci_scan_bus(phb, pd->secondary_bus,
+			     pd->subordinate_bus, &pd->children, pd, true);
+		pci_add_device_nodes(phb, &pd->children, pd->dn,
+				     &phb->lstate, 0);
+	} else {
+		pci_scan_bus(phb, 0, 0xff, &phb->devices, NULL, true);
+		pci_add_device_nodes(phb, &phb->devices,
+				     phb->dt_node, &phb->lstate, 0);
+		phb->ops->phb_final_fixup(phb);
+	}
 }
 
 static void remove_slot_devices(struct pci_slot *slot)
@@ -675,7 +682,10 @@  static void remove_slot_devices(struct pci_slot *slot)
 	struct phb *phb = slot->phb;
 	struct pci_device *pd = slot->pd;
 
-	pci_remove_bus(phb, &pd->children);
+	if (phb->phb_type != phb_type_npu_v2_opencapi)
+		pci_remove_bus(phb, &pd->children);
+	else
+		pci_remove_bus(phb, &phb->devices);
 }
 
 static void link_training_timer(struct timer *t, void *data,