From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82EF63C871D for ; Sat, 1 Aug 2026 20:12:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785615179; cv=none; b=BqLDQZegbV5OU+2nsCCJYUazLYNlgawQtRnBmWpqasW7E5i0i+b7eetW1NsHI7YXV+TOY9gc9b6VrUkYPpzCY8LjHr9vpJWvZaTWaERy0TTpiMpmrSaOmKQcc3dIzDW8sf1RXxlqbjBy/j+xtuJiTUfF5dQEWW5QFdK8UUUFX3w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785615179; c=relaxed/simple; bh=pwGUVQeAwLqIv1Pp+rYmOL0ItKo7N0odQK6waLjAx3E=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=VnqJoXK/ZpYw+kn+iXnHOfpBi4iFtsHzYLcFoqnwXGMzoiFg9p9FTWtKLtJ3dni8ruxrokpexmmShFlkWbxL/eEVWAdYqMYOALAtDXXbW9mBDhFKpTnHf9U5wkVhxhyQKGjN004L00toKZZnN98jP/JJ074B7l9jD6UOgUiD6ic= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UfiUqnEj; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UfiUqnEj" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4980dc26022so3896025e9.1 for ; Sat, 01 Aug 2026 13:12:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785615175; x=1786219975; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=oe1Uqys8z7ztet5O0i2nlWAxABim+wh4xZLaDprfIlI=; b=UfiUqnEjZeaB1MX9SvWhlq7EG142d7s2yyMQL0prZywx4tNrjMaZLldACgOMnG+I52 1etQnrqS+kD8+9OPAxyful8bbj7y3nrivbZufMTKPZ3zCpQvUxcDEMa2TfQSydTBSU9/ DfgPPTGfhwovpiVkdWnJTAV+zwmebEbiaxblzTb8GMRlm5Dck1C2mCdDcU+fjkzWlV7U CzHBYihI9bTeOypLmvj3576J4WmLH+e7PDURF1Tw0eeJDyAbx4WfFHReKA0WZpOKcGuo LijrVK4JAcPtBIQEDWN3hhJgiN016C1PkaHvZusWYaZZu+MT32O3iXf6OkT0cqwz4BKX Zyyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785615175; x=1786219975; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=oe1Uqys8z7ztet5O0i2nlWAxABim+wh4xZLaDprfIlI=; b=VAz/MZQP1nvicZGtypfZj5bd+5FLAKcMHPaW/qnTo2pkK63C1O83cvS9ntXaEcoPd5 Yj5nkkejozldh++qUGRO+lPbe/GOHRzmQmnNy1/2ffkk8AYDyX5TfIitig1wHa5k573m IQ9eazvIkoZ2BafiUK8GqzFtZI/QUYGeDCdJzEKz9QKnkbIWmvheKw9FE9ckuGbI65SG 7FRdhev7akirSxVxXwsKd2wG2V0Pixd2rqyN0OkPpARiEK5HQD+5osYvrPINcJz4b4jt 1/qu2ueOQBvr/Q9t8Qy0AX0CMW6OE8MCvcE6JcQdI3lQPnJ5HF2lA7ffgVH8keKmH+1y BKww== X-Forwarded-Encrypted: i=1; AHgh+Ro9fAuBGE7hq4R7dlVPqKvJP5X/aH1sEYiTAq+Iv5N0g6N1JwVY4I/bMgFJ/5MZDwBPrEr01wMcEAiMYl0=@vger.kernel.org X-Gm-Message-State: AOJu0YxvHEZ4T6V0GxoREPyu0w9LLdPUx5GiROnCg5SNT2uXfNdbYh98 IPQYaUSuHQ3k/Z0ObSUx7d79eCiSyHtNKtg4enrAWT3YnCaTAFC8dkxo X-Gm-Gg: AR+sD10zEvoeZoNd8a28ZWvtk0R0fxsIT8sXtrTjO4PJWJ+DP6CGkPjKhCP7y5Xg+yx WcPMXStiAY1R5fTlekjrRwyOR+Kr6mkzpMElmxzlCBifZ07nHMTaM24UmhZqLkX1M385slOq7uJ +1mGAYROyAP7ahB7fqeMnE//qICd1AUVuzzKMhEDFQMvvWpaliY6syZfV3QpQMX0ayal0GoUaSl Hhy+a8De4TjOUS+tosYGQHDTsZ9gPpw8ekS0vk/3Q31C9BFD+b31+SVEsTV8/x7Mteg/cG6gBIj vguRMw2cMafCPOuSFwzAe+WLvfZWJhPNwhtSN0gGTUv0mhfwlAnud4VhuRma5kDMEFuWS4s9jmj YGayOc0fOSdufCcSEA07z7mejbV31iRygL+mLNUxeuc7QRY4PgFsnoMoaCTrpNIoccATfcAmbrW uwu6IL3p1E8JxbMuS5VSPtaPB0m8VD2g2PbDvTKfEib7774rtaRAe9cEdRCg16uNZf9+CYusIBa BqHQsJ5d0Q3BWILhThkaLMWnbWBSzc03i1c4ow5klP9qFKJoGsMhUDN1vO0+zvUuqsTquAWNcIO l4EVjGiBJcqkucar326evNaXzld+fgSjBSeUP8rhpMs= X-Received: by 2002:a05:600c:548d:b0:495:6134:6d61 with SMTP id 5b1f17b1804b1-4980c674de0mr84288285e9.19.1785615175066; Sat, 01 Aug 2026 13:12:55 -0700 (PDT) Received: from corecachy.localdomain (p200300eca72356fc3569cec583d57196.dip0.t-ipconnect.de. [2003:ec:a723:56fc:3569:cec5:83d5:7196]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49807ba13e9sm119585385e9.13.2026.08.01.13.12.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 13:12:54 -0700 (PDT) From: Andreas Wild To: linux-pci@vger.kernel.org Cc: bhelgaas@google.com, macro@orcam.me.uk, linux-kernel@vger.kernel.org, Andreas Wild Subject: [PATCH v3] PCI: Skip Target Speed quirk on clamped ports with no link Date: Sat, 1 Aug 2026 22:11:48 +0200 Message-ID: <20260801201244.4421-1-andiwild@gmail.com> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Maciej W. Rozycki" 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 Closes: https://lore.kernel.org/lkml/20260801092152.5643-1-andiwild@gmail.com/ Tested-by: Andreas Wild Signed-off-by: Maciej W. Rozycki Signed-off-by: Andreas Wild --- 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