diff mbox

[v2,5/9] core/pci: Get PCI slot before applying quirk

Message ID 1476321413-5245-6-git-send-email-gwshan@linux.vnet.ibm.com
State Changes Requested
Headers show

Commit Message

Gavin Shan Oct. 13, 2016, 1:16 a.m. UTC
We might need know the associated PCI slot before applying the chip
level quirk (phb->ops->device_init()) so that special configuration
on the specific PCI slot can be applied.

This moves the logic of creating PCI slot, applying the quirk and
linking the newly probed device to parent's child list to function
pci_scan_one(). Also, the PCI slot is created prior to applying the
quirk.

Cc: stable # 5.3.0+
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
 core/pci.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
diff mbox

Patch

diff --git a/core/pci.c b/core/pci.c
index 30307c9..0c93fd9 100644
--- a/core/pci.c
+++ b/core/pci.c
@@ -259,6 +259,16 @@  static struct pci_device *pci_scan_one(struct phb *phb, struct pci_device *paren
 	       pd->is_bridge ? "+" : "-",
 	       pci_has_cap(pd, PCI_CFG_CAP_ID_EXP, false) ? "+" : "-");
 
+	/* Try to get PCI slot behind the device */
+	if (platform.pci_get_slot_info)
+		platform.pci_get_slot_info(phb, pd);
+
+	/* Put it to the child device of list of PHB or parent */
+	if (!parent)
+		list_add_tail(&phb->devices, &pd->link);
+	else
+		list_add_tail(&parent->children, &pd->link);
+
 	/*
 	 * Call PHB hook
 	 */
@@ -566,13 +576,6 @@  uint8_t pci_scan_bus(struct phb *phb, uint8_t bus, uint8_t max_bus,
 		if (!pd)
 			continue;
 
-		/* Get slot info if any */
-		if (platform.pci_get_slot_info)
-			platform.pci_get_slot_info(phb, pd);
-
-		/* Link it up */
-		list_add_tail(list, &pd->link);
-
 		/* XXX Handle ARI */
 		if (!pd->is_multifunction)
 			continue;
@@ -580,11 +583,6 @@  uint8_t pci_scan_bus(struct phb *phb, uint8_t bus, uint8_t max_bus,
 			pd = pci_scan_one(phb, parent,
 					  ((uint16_t)bus << 8) | (dev << 3) | fn);
 			pci_check_clear_freeze(phb);
-			if (pd) {
-				if (platform.pci_get_slot_info)
-					platform.pci_get_slot_info(phb, pd);
-				list_add_tail(list, &pd->link);
-			}
 		}
 	}