mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] PCI: Skip Target Speed quirk on clamped ports with no link
@ 2026-08-01 20:11 Andreas Wild
  2026-08-03  5:39 ` Thorsten Leemhuis
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Andreas Wild @ 2026-08-01 20:11 UTC (permalink / raw)
  To: linux-pci; +Cc: bhelgaas, macro, linux-kernel, Andreas Wild

From: "Maciej W. Rozycki" <macro@orcam.me.uk>

Since commit 72780f796468 ("PCI: Always lift 2.5GT/s restriction in PCIe
failed link retraining") the Target Speed quirk lifts a firmware-imposed
2.5GT/s restriction on any downstream port, without checking whether the
link is up.  Where nothing is plugged in, the retraining that follows can
never complete, so each attempt costs PCIE_LINK_RETRAIN_TIMEOUT_MS.  The
quirk makes two of them -- the initial one and the restore on the error
path -- adding a fixed 2 s to every boot.

On an MSI PRO Z690-A WIFI DDR4 (Intel 600 Series PCH) with one empty x1
slot, running v7.2-rc5:

 0.541 pci 0000:00:1c.0: removing 2.5GT/s downstream link speed restriction
 1.541 pci 0000:00:1c.0: retraining failed
 2.541 pci 0000:00:1c.2: [8086:7aba] type 01 class 0x060400

Where the Link Speed has already been clamped at 2.5GT/s and no link has
been established there is nothing worth doing, which is what the kerneldoc
for the quirk already describes: the restriction is to be lifted where
firmware arranged it "and the port reports its link already being up".
Bail out early in that case, before either the ASM2824 workaround or the
removal of the restriction is considered.

Ports whose link is up are unaffected, and so is the ASM2824 workaround,
which is reached with the Target Link Speed not clamped.

With this applied the quirk returns without touching the port: both
messages are gone, enumeration proceeds from 0000:00:1c.0 to 0000:00:1c.2
in 1 ms rather than 2 s, and the systemd "kernel" boot phase goes from
3.011 s to 1.036 s.

Fixes: 72780f796468 ("PCI: Always lift 2.5GT/s restriction in PCIe failed link retraining")
Cc: stable@vger.kernel.org
Reported-by: Andreas Wild <andiwild@gmail.com>
Closes: https://lore.kernel.org/lkml/20260801092152.5643-1-andiwild@gmail.com/
Tested-by: Andreas Wild <andiwild@gmail.com>
Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
Signed-off-by: Andreas Wild <andiwild@gmail.com>
---
v3:
 - Replaced with Maciej's much simpler approach: bail out of the quirk
   entirely when the Target Link Speed is already clamped at 2.5GT/s and no
   link has been established, rather than programming the speed and skipping
   only the retraining.  One function, no new API, no bwctrl changes.
 - Note this leaves the Target Link Speed clamped on such a port, where v2
   left it at the Port's maximum.  A device hot-plugged there later trains at
   2.5GT/s: pcie_wait_for_link_delay() only calls the quirk when
   pcie_wait_for_link_status() fails, so a link that comes up cleanly at
   2.5GT/s never re-runs it.  Flagging in case that matters; the clamp is
   firmware's, so honouring it on an unoccupied Port seems defensible.
 - v2: https://lore.kernel.org/lkml/20260801105441.6506-1-andiwild@gmail.com/
 - v1: https://lore.kernel.org/lkml/20260801092152.5643-1-andiwild@gmail.com/
 drivers/pci/quirks.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index b09f27f..9e407c4 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -108,7 +108,11 @@ int pcie_failed_link_retrain(struct pci_dev *dev)
 
 	pcie_capability_read_word(dev, PCI_EXP_LNKSTA, &lnksta);
 	pcie_capability_read_word(dev, PCI_EXP_LNKCTL2, &oldlnkctl2);
-	if (!(lnksta & PCI_EXP_LNKSTA_DLLLA) && pcie_lbms_seen(dev, lnksta)) {
+	if (lnksta & PCI_EXP_LNKSTA_DLLLA) {
+		;
+	} else if (PCIE_LNKCTL2_TLS2SPEED(oldlnkctl2) == PCIE_SPEED_2_5GT) {
+		return ret;
+	} else if (pcie_lbms_seen(dev, lnksta)) {
 		pci_info(dev, "broken device, retraining non-functional downstream link at 2.5GT/s\n");
 		ret = pcie_set_target_speed(dev, PCIE_SPEED_2_5GT, false);
 		if (ret)
-- 
2.55.0


^ permalink raw reply	[flat|nested] 21+ messages in thread
* Re: [PATCH v3] PCI: Skip Target Speed quirk on clamped ports with no link
@ 2026-09-20  8:15 blaat windows
  0 siblings, 0 replies; 21+ messages in thread
From: blaat windows @ 2026-09-20  8:15 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-kernel, regressions

Another reproducible case of the active-link failure described in this thread.

Hardware:
Intel 4th-gen/9-series platform
Intel 82571EB quad-port NIC
Microsemi/PMC/IDT PES12N3A PCIe switch
Root port 00:1c.4, LnkCap 5GT/s x4
Working negotiated link: 2.5GT/s x4

Kernel results:
7.2-rc1 fail
7.1-rc7 succes

On failing kernels, the PES12N3A hierarchy does not enumerate and all four downstream 82571EB ports disappear.

I traced this to pcie_failed_link_retrain() and specifically the new generic clamp-removal code introduced by 72780f7964684939d7d2f69c348876213b184484 ("PCI: Always lift 2.5GT/s restriction in PCIe failed link retraining").

I tested 7.3.0-rc3+ with only this block commented out:

    pcie_capability_read_word(dev, PCI_EXP_LNKCTL2, &lnkctl2);
    if ((lnkctl2 & PCI_EXP_LNKCTL2_TLS) == PCI_EXP_LNKCTL2_TLS_2_5GT) {
            pci_info(dev, "removing 2.5GT/s downstream link speed restriction\n");
            ret = pcie_set_target_speed(dev, speed_cap, false);
            if (ret)
                    goto err;
    }

With that block disabled, 7.3.0-rc3+ boots normally, having all four NIC ports enumerate:

07:00.0 82571EB
07:00.1 82571EB
08:00.0 82571EB
08:00.1 82571EB

The important result is that the initial 2.5GT/s recovery is fine. Leaving the link at 2.5GT/s works. It is the subsequent:

    pcie_set_target_speed(dev, speed_cap, false);

which breaks this PES12N3A/82571EB link.

So this appears to be the same active-link failure mode, but with a PES12N3A switch rather than a direct 82571EB connection.

This was tested against vanilla 7.3.0-rc3+ with only the above local change.

I can provide full dmesg/lspci output and test a proposed fix if useful.

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

end of thread, other threads:[~2026-09-21 10:33 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-01 20:11 [PATCH v3] PCI: Skip Target Speed quirk on clamped ports with no link Andreas Wild
2026-08-03  5:39 ` Thorsten Leemhuis
2026-08-03 22:07   ` Maciej W. Rozycki
2026-08-04  5:32     ` Thorsten Leemhuis
2026-08-07 19:59 ` Aoxtj
2026-08-08  6:31   ` Andreas Wild
2026-08-11  3:43     ` Aoxtj
2026-08-11  6:42       ` Andreas Wild
2026-08-24 14:26         ` Thorsten Leemhuis
2026-08-25  7:05           ` Andreas Wild
2026-08-25 10:18             ` Maciej W. Rozycki
2026-09-02 15:48               ` Thorsten Leemhuis
2026-09-07 12:33                 ` Maciej W. Rozycki
2026-09-17 23:33 ` Bjorn Helgaas
2026-09-18  5:39   ` Thorsten Leemhuis
2026-09-18 10:39     ` Maciej W. Rozycki
2026-09-18 11:00       ` Thorsten Leemhuis
2026-09-18 12:18         ` Maciej W. Rozycki
2026-09-18 12:50           ` Thorsten Leemhuis
2026-09-21 10:33       ` Thorsten Leemhuis
2026-09-20  8:15 blaat windows

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

all inboxes | Powered by JetHome®