Skip to contentSkip to conversation

PCI: Set supported_speeds in set_pcie_port_type()

PATCH In review Stian Halseth 4 participants 4 messages Oct 7 – Oct 14 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: Set supported_speeds in set_pcie_port_type()

sparc64 and powerpc create PCI devices from the device tree in of_create_pci_dev(), which calls set_pcie_port_type() but not pci_setup_device(). Since d2bd39c0456b, supported_speeds is only set in pci_setup_device(), so it stays 0 for these devices. pcie_get_speed_cap() then returns PCI_SPEED_UNKNOWN, max_link_speed reads "Unknown", and the failed link retraining quirk passes PCI_SPEED_UNKNOWN to pcie_set_target_speed(), which warns on a SPARC T7-1:

  WARNING: drivers/pci/pcie/bwctrl.c:125 at pcie_set_target_speed+0x284/0x2e0

Set supported_speeds in set_pcie_port_type(), which all three paths call.

Fixes d2bd39c0456b ("PCI: Store all PCIe Supported Link Speeds")

---
Tested on a SPARC T7-1: before, max_link_speed reads "Unknown" and the warning above appears with CONFIG_PCIEPORTBUS; after, all 23 PCIe devices report their real speed and the quirk lifts the 2.5GT/s restriction without a warning. Not tested on powerpc.

 drivers/pci/probe.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pci/probe.c +2 -3
index 27008e2ea5afc..52a79b033b069 100644
@@ -1651,6 +1651,8 @@ void set_pcie_port_type(struct pci_dev *pdev)
 		pdev->aspm_l1_support = 1;
 #endif
 
+	pdev->supported_speeds = pcie_get_supported_speeds(pdev);
+
 	parent = pci_upstream_bridge(pdev);
 	if (!parent)
 		return;
@@ -2074,9 +2076,6 @@ int pci_setup_device(struct pci_dev *dev)
 
 	set_pcie_untrusted(dev);
 
-	if (pci_is_pcie(dev))
-		dev->supported_speeds = pcie_get_supported_speeds(dev);
-
 	/* "Unknown power state" */
 	dev->current_state = PCI_UNKNOWN;
 
Signature · 1 line
2.43.0
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines

sparc64 and powerpc create PCI devices from the device tree in of_create_pci_dev(), which calls set_pcie_port_type() but not pci_setup_device(). Since d2bd39c0456b, supported_speeds is only set in pci_setup_device(), so it stays 0 for these devices. pcie_get_speed_cap() then returns PCI_SPEED_UNKNOWN, max_link_speed reads "Unknown", and the failed link retraining quirk passes PCI_SPEED_UNKNOWN to pcie_set_target_speed(), which warns on a SPARC T7-1:

Quoted 8 lines
  WARNING: drivers/pci/pcie/bwctrl.c:125 at pcie_set_target_speed+0x284/0x2e0

Set supported_speeds in set_pcie_port_type(), which all three paths call.

Fixes d2bd39c0456b ("PCI: Store all PCIe Supported Link Speeds")

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Tested-by on v1 1/1
#2 lore raw
In reply to Stian Halseth

This patch also works on the Sparc S7-2, the correct x8 link is shown instead of unknown.

# dmesg | grep -iE x8 | grep -iE link
[    8.421411] mlx5_core 0001:03:00.0: 63.008 Gb/s available PCIe bandwidth (8.0 GT/s PCIe x8 link)
[    9.472465] mlx5_core 0001:03:00.1: 63.008 Gb/s available PCIe bandwidth (8.0 GT/s PCIe x8 link)
[   14.734746] mlx4_core 0001:04:00.0: 63.008 Gb/s available PCIe bandwidth (8.0 GT/s PCIe x8 link)
Quoted 49 lines · Stian Halseth

sparc64 and powerpc create PCI devices from the device tree in of_create_pci_dev(), which calls set_pcie_port_type() but not pci_setup_device(). Since d2bd39c0456b, supported_speeds is only set in pci_setup_device(), so it stays 0 for these devices. pcie_get_speed_cap() then returns PCI_SPEED_UNKNOWN, max_link_speed reads "Unknown", and the failed link retraining quirk passes PCI_SPEED_UNKNOWN to pcie_set_target_speed(), which warns on a SPARC T7-1:

   WARNING: drivers/pci/pcie/bwctrl.c:125 at pcie_set_target_speed+0x284/0x2e0

Set supported_speeds in set_pcie_port_type(), which all three paths call.

Fixes d2bd39c0456b ("PCI: Store all PCIe Supported Link Speeds")

---
Tested on a SPARC T7-1: before, max_link_speed reads "Unknown" and the warning above appears with CONFIG_PCIEPORTBUS; after, all 23 PCIe devices report their real speed and the quirk lifts the 2.5GT/s restriction without a warning. Not tested on powerpc.

  drivers/pci/probe.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pci/probe.c +2 -3
index 27008e2ea5afc..52a79b033b069 100644
@@ -1651,6 +1651,8 @@ void set_pcie_port_type(struct pci_dev *pdev)
  		pdev->aspm_l1_support = 1;
  #endif
 
+	pdev->supported_speeds = pcie_get_supported_speeds(pdev);
+
  	parent = pci_upstream_bridge(pdev);
  	if (!parent)
  		return;
@@ -2074,9 +2076,6 @@ int pci_setup_device(struct pci_dev *dev)
 
  	set_pcie_untrusted(dev);
 
-	if (pci_is_pcie(dev))
-		dev->supported_speeds = pcie_get_supported_speeds(dev);
-
  	/* "Unknown power state" */
  	dev->current_state = PCI_UNKNOWN;
 
#3 lore raw
In reply to Stian Halseth

[+cc Tony]

Quoted 9 lines · Stian Halseth

sparc64 and powerpc create PCI devices from the device tree in of_create_pci_dev(), which calls set_pcie_port_type() but not pci_setup_device(). Since d2bd39c0456b, supported_speeds is only set in pci_setup_device(), so it stays 0 for these devices. pcie_get_speed_cap() then returns PCI_SPEED_UNKNOWN, max_link_speed reads "Unknown", and the failed link retraining quirk passes PCI_SPEED_UNKNOWN to pcie_set_target_speed(), which warns on a SPARC T7-1:

Quoted 8 lines
  WARNING: drivers/pci/pcie/bwctrl.c:125 at pcie_set_target_speed+0x284/0x2e0

Set supported_speeds in set_pcie_port_type(), which all three paths call.

Fixes d2bd39c0456b ("PCI: Store all PCIe Supported Link Speeds")

Applied with Tony's Tested-by to pci/enumeration for v7.4, thanks!

I added a stable tag since d2bd39c0456b appeared in v6.13.

Quoted 35 lines

---
Tested on a SPARC T7-1: before, max_link_speed reads "Unknown" and the warning above appears with CONFIG_PCIEPORTBUS; after, all 23 PCIe devices report their real speed and the quirk lifts the 2.5GT/s restriction without a warning. Not tested on powerpc.

 drivers/pci/probe.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pci/probe.c +2 -3
index 27008e2ea5afc..52a79b033b069 100644
@@ -1651,6 +1651,8 @@ void set_pcie_port_type(struct pci_dev *pdev)
 		pdev->aspm_l1_support = 1;
 #endif
 
+	pdev->supported_speeds = pcie_get_supported_speeds(pdev);
+
 	parent = pci_upstream_bridge(pdev);
 	if (!parent)
 		return;
@@ -2074,9 +2076,6 @@ int pci_setup_device(struct pci_dev *dev)
 
 	set_pcie_untrusted(dev);
 
-	if (pci_is_pcie(dev))
-		dev->supported_speeds = pcie_get_supported_speeds(dev);
-
 	/* "Unknown power state" */
 	dev->current_state = PCI_UNKNOWN;
 
Signature · 1 line
2.43.0