Skip to content

Commit 777e61e

Browse files
YijingWangbjorn-helgaas
authored andcommitted
PCI: Use dev->has_secondary_link to find downstream PCIe links
Previously we assumed that PCIe Root Ports and Downstream Ports had Links on their secondary side. That is true in most systems, but it is possible to connect a switch with either an Upstream or a Downstream Port leading downstream. Instead of relying on the component type to identify devices that have links leading downstream, use the "dev->has_secondary_link" field. [bhelgaas: changelog] Signed-off-by: Yijing Wang <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent c8fc933 commit 777e61e

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

drivers/pci/pcie/aer/aerdrv_core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,7 @@ static pci_ers_result_t reset_link(struct pci_dev *dev)
425425

426426
if (driver && driver->reset_link) {
427427
status = driver->reset_link(udev);
428-
} else if (pci_pcie_type(udev) == PCI_EXP_TYPE_DOWNSTREAM ||
429-
pci_pcie_type(udev) == PCI_EXP_TYPE_ROOT_PORT) {
428+
} else if (udev->has_secondary_link) {
430429
status = default_reset_link(udev);
431430
} else {
432431
dev_printk(KERN_DEBUG, &dev->dev,

drivers/pci/probe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1629,7 +1629,7 @@ static int only_one_child(struct pci_bus *bus)
16291629
return 0;
16301630
if (pci_pcie_type(parent) == PCI_EXP_TYPE_ROOT_PORT)
16311631
return 1;
1632-
if (pci_pcie_type(parent) == PCI_EXP_TYPE_DOWNSTREAM &&
1632+
if (parent->has_secondary_link &&
16331633
!pci_has_flag(PCI_SCAN_ALL_PCIE_DEVS))
16341634
return 1;
16351635
return 0;

drivers/pci/vc.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ static void pci_vc_enable(struct pci_dev *dev, int pos, int res)
108108
struct pci_dev *link = NULL;
109109

110110
/* Enable VCs from the downstream device */
111-
if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT ||
112-
pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM)
111+
if (!dev->has_secondary_link)
113112
return;
114113

115114
ctrl_pos = pos + PCI_VC_RES_CTRL + (res * PCI_CAP_VC_PER_VC_SIZEOF);

0 commit comments

Comments
 (0)