commit 75eaf674066590e79b3e03d32488871fc881ab40 Author: Bjorn Helgaas Date: Thu Nov 30 15:22:39 2017 -0600 PCI: Make PCI_SCAN_ALL_PCIE_DEVS work for Root Ports as well as Downstream Previously PCI_SCAN_ALL_PCIE_DEVS (set by quirks or the "pci=pcie_scan_all" kernel parameter) only affected Switch Downstream Ports, not Root Ports. Simplify and restructure only_one_child() so PCI_SCAN_ALL_PCIE_DEVS means we scan for all possible devices below Root Ports as well as Switch Downstream Ports. Signed-off-by: Bjorn Helgaas diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 14e0ea1ff38b..9e57d4ef0c1f 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2217,20 +2217,28 @@ static int only_one_child(struct pci_bus *bus) { struct pci_dev *parent = bus->self; - if (!parent || !pci_is_pcie(parent)) + if (!parent) + return 0; + + /* + * Systems with unusual topologies set PCI_SCAN_ALL_PCIE_DEVS so + * we scan for all possible devices, not just Device 0. + */ + if (pci_has_flag(PCI_SCAN_ALL_PCIE_DEVS)) return 0; - if (pci_pcie_type(parent) == PCI_EXP_TYPE_ROOT_PORT) - return 1; /* - * PCIe downstream ports are bridges that normally lead to only a - * device 0, but if PCI_SCAN_ALL_PCIE_DEVS is set, scan all - * possible devices, not just device 0. See PCIe spec r3.0, - * sec 7.3.1. + * A PCIe Downstream Port normally leads to a Link with only Device + * 0 on it (PCIe spec r3.1, sec 7.3.1). As an optimization, scan + * only for Device 0 in that situation. + * + * Checking has_secondary_link is a hack to identify Downstream + * Ports because sometimes Switches are configured such that the + * PCIe Port Type labels are backwards. */ - if (parent->has_secondary_link && - !pci_has_flag(PCI_SCAN_ALL_PCIE_DEVS)) + if (pci_is_pcie(parent) && parent->has_secondary_link) return 1; + return 0; }