Skip to contentSkip to conversation

PCI/ASPM: Don't retrain link if ASPM not possible.

PATCH Applied David Daney 3 participants 4 messages Nov 17, 2016 – Dec 8, 2016 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI/ASPM: Don't retrain link if ASPM not possible.

From: David Daney <[email protected]>

Some (defective) PCIe devices are not able to reliably do link retraining.

Check to see if ASPM is possible between link partners before configuring common clocking, and doing the resulting link retraining. If ASPM is not possible, there is no reason to risk losing access to a device due to an unnecessary link retraining.

---
 drivers/pci/pcie/aspm.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/pci/pcie/aspm.c +16 -2
index 0ec649d..d6667db 100644
@@ -351,12 +351,26 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
 		return;
 	}
 
+	/* Get upstream/downstream components' register state */
+	pcie_get_aspm_reg(parent, &upreg);
+	child = list_entry(linkbus->devices.next, struct pci_dev, bus_list);
+	pcie_get_aspm_reg(child, &dwreg);
+
+	/*
+	 * If ASPM not supported, don't mess with the clocks and link,
+	 * bail out now.
+	 */
+	if (!(upreg.support & dwreg.support))
+		return;
+
 	/* Configure common clock before checking latencies */
 	pcie_aspm_configure_common_clock(link);
 
-	/* Get upstream/downstream components' register state */
+	/*
+	 * Re-read upstream/downstream components' register state
+	 * after clock configuration
+	 */
 	pcie_get_aspm_reg(parent, &upreg);
-	child = list_entry(linkbus->devices.next, struct pci_dev, bus_list);
 	pcie_get_aspm_reg(child, &dwreg);
 
 	/*
Signature · 1 line
1.7.11.7
#1 lore raw

Ping: [PATCH] PCI/ASPM: Don't retrain link if ASPM not possible.

Quoted 10 lines · David Daney

From: David Daney <[email protected]>

Some (defective) PCIe devices are not able to reliably do link retraining.

Check to see if ASPM is possible between link partners before configuring common clocking, and doing the resulting link retraining. If ASPM is not possible, there is no reason to risk losing access to a device due to an unnecessary link retraining.

Hi Bjorn,

It has been a couple of weeks since I originally sent this, and I wanted to know if you have had a chance to look at it. If possible, it would be nice to consider for the approaching merge window.

Thanks,
David Daney

Quoted 39 lines
---
  drivers/pci/pcie/aspm.c | 18 ++++++++++++++++--
  1 file changed, 16 insertions(+), 2 deletions(-)
drivers/pci/pcie/aspm.c +16 -2
index 0ec649d..d6667db 100644
@@ -351,12 +351,26 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
  		return;
  	}
 
+	/* Get upstream/downstream components' register state */
+	pcie_get_aspm_reg(parent, &upreg);
+	child = list_entry(linkbus->devices.next, struct pci_dev, bus_list);
+	pcie_get_aspm_reg(child, &dwreg);
+
+	/*
+	 * If ASPM not supported, don't mess with the clocks and link,
+	 * bail out now.
+	 */
+	if (!(upreg.support & dwreg.support))
+		return;
+
  	/* Configure common clock before checking latencies */
  	pcie_aspm_configure_common_clock(link);
 
-	/* Get upstream/downstream components' register state */
+	/*
+	 * Re-read upstream/downstream components' register state
+	 * after clock configuration
+	 */
  	pcie_get_aspm_reg(parent, &upreg);
-	child = list_entry(linkbus->devices.next, struct pci_dev, bus_list);
  	pcie_get_aspm_reg(child, &dwreg);
 
  	/*
#2 lore raw

Re: Ping: [PATCH] PCI/ASPM: Don't retrain link if ASPM not possible.

Hi David,

Quoted 12 lines · David Daney
Quoted 10 lines · David Daney

From: David Daney <[email protected]>

Some (defective) PCIe devices are not able to reliably do link retraining.

Check to see if ASPM is possible between link partners before configuring common clocking, and doing the resulting link retraining. If ASPM is not possible, there is no reason to risk losing access to a device due to an unnecessary link retraining.

Quoted 5 lines

Hi Bjorn,

It has been a couple of weeks since I originally sent this, and I wanted to know if you have had a chance to look at it. If possible, it would be nice to consider for the approaching merge window.

Yes, definitely. I haven't had a chance yet, but I hope to. Right now my top priority is getting the arm64 ECAM quirks in for v4.10. Once that's settled I'll come back and pick up some of these fixes.

Bjorn

#3 lore raw
In reply to David Daney
Quoted 11 lines · David Daney

From: David Daney <[email protected]>

Some (defective) PCIe devices are not able to reliably do link retraining.

Check to see if ASPM is possible between link partners before configuring common clocking, and doing the resulting link retraining. If ASPM is not possible, there is no reason to risk losing access to a device due to an unnecessary link retraining.

Applied to pci/aspm for v4.10, thanks, David!

Quoted 44 lines
---
 drivers/pci/pcie/aspm.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/pci/pcie/aspm.c +16 -2
index 0ec649d..d6667db 100644
@@ -351,12 +351,26 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
 		return;
 	}
 
+	/* Get upstream/downstream components' register state */
+	pcie_get_aspm_reg(parent, &upreg);
+	child = list_entry(linkbus->devices.next, struct pci_dev, bus_list);
+	pcie_get_aspm_reg(child, &dwreg);
+
+	/*
+	 * If ASPM not supported, don't mess with the clocks and link,
+	 * bail out now.
+	 */
+	if (!(upreg.support & dwreg.support))
+		return;
+
 	/* Configure common clock before checking latencies */
 	pcie_aspm_configure_common_clock(link);
 
-	/* Get upstream/downstream components' register state */
+	/*
+	 * Re-read upstream/downstream components' register state
+	 * after clock configuration
+	 */
 	pcie_get_aspm_reg(parent, &upreg);
-	child = list_entry(linkbus->devices.next, struct pci_dev, bus_list);
 	pcie_get_aspm_reg(child, &dwreg);
 
 	/*
Signature · 6 lines
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html