Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH] PCI: Set supported_speeds in set_pcie_port_type()
@ 2026-10-07 13:13 Stian Halseth
  2026-10-07 13:22 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Stian Halseth @ 2026-10-07 13:13 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Ilpo Järvinen, Andreas Larsson, linux-pci, sparclinux,
	linuxppc-dev, linux-kernel, 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")
Closes: https://github.com/sparclinux/issues/issues/109
Signed-off-by: Stian Halseth <stian@itx.no>
---
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(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 27008e2ea5afc..52a79b033b069 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -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;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] PCI: Set supported_speeds in set_pcie_port_type()
  2026-10-07 13:13 [PATCH] PCI: Set supported_speeds in set_pcie_port_type() Stian Halseth
@ 2026-10-07 13:22 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-10-07 13:22 UTC (permalink / raw)
  To: Stian Halseth; +Cc: linux-pci

> 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")
> Closes: https://github.com/sparclinux/issues/issues/109
> Signed-off-by: Stian Halseth <stian@itx.no>

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

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261007131304.309511-1-stian@itx.no?part=1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-07 13:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-07 13:13 [PATCH] PCI: Set supported_speeds in set_pcie_port_type() Stian Halseth
2026-10-07 13:22 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox