Skip to contentSkip to conversation

PCI: Use pdev->has_secondary_link to identify pcie link

PATCH Superseded Yijing Wang 1 participant 1 message May 19, 2015 PCI

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 2/2 PCI: Use pdev->has_secondary_link to identify pcie link

We assumed pcie root port and downstream port always have pcie link, but in some unusual pcie topology platform like ATCA, it may has the following pcie tree:

root port ---- downstream port -----upstream port

                                   |
                                   |downstream port

Now we introduce a flag pdev->has_secondary_link to tag a device whether has pcie link, use it instead.

---
 drivers/pci/pcie/aer/aerdrv_core.c |    3 +--
 drivers/pci/probe.c                |    2 +-
 drivers/pci/vc.c                   |    3 +--
 3 files changed, 3 insertions(+), 5 deletions(-)
drivers/pci/pcie/aer/aerdrv_core.c +1 -2
index 5653ea9..9803e3d 100644
@@ -425,8 +425,7 @@ static pci_ers_result_t reset_link(struct pci_dev *dev)
 
 	if (driver && driver->reset_link) {
 		status = driver->reset_link(udev);
-	} else if (pci_pcie_type(udev) == PCI_EXP_TYPE_DOWNSTREAM ||
-		pci_pcie_type(udev) == PCI_EXP_TYPE_ROOT_PORT) {
+	} else if (udev->has_secondary_link) {
 		status = default_reset_link(udev);
 	} else {
 		dev_printk(KERN_DEBUG, &dev->dev,
drivers/pci/probe.c +1 -1
index ad26ff2..d2627d3 100644
@@ -1641,7 +1641,7 @@ static int only_one_child(struct pci_bus *bus)
 		return 0;
 	if (pci_pcie_type(parent) == PCI_EXP_TYPE_ROOT_PORT)
 		return 1;
-	if (pci_pcie_type(parent) == PCI_EXP_TYPE_DOWNSTREAM &&
+	if (parent->has_secondary_link &&
 	    !pci_has_flag(PCI_SCAN_ALL_PCIE_DEVS))
 		return 1;
 	return 0;
drivers/pci/vc.c +1 -2
index 7e1304d..dfbab61 100644
@@ -108,8 +108,7 @@ static void pci_vc_enable(struct pci_dev *dev, int pos, int res)
 	struct pci_dev *link = NULL;
 
 	/* Enable VCs from the downstream device */
-	if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT ||
-	    pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM)
+	if (!dev->has_secondary_link)
 		return;
 
 	ctrl_pos = pos + PCI_VC_RES_CTRL + (res * PCI_CAP_VC_PER_VC_SIZEOF);
Signature · 1 line
1.7.1