From 39aad95618fea977464bfc38ec0c190075a26304 Mon Sep 17 00:00:00 2001 From: Gavin Shan Date: Fri, 14 Oct 2016 15:26:03 +1100 Subject: core/pci: Get PCI slot before applying quirk 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 Signed-off-by: Stewart Smith --- core/pci.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/core/pci.c b/core/pci.c index 6a1dabc..07b15d8 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); - } } } -- cgit v1.1