From: Yifan Zhang <yifan1.zhang@amd.com>
To: <bhelgaas@google.com>, <Alexander.Deucher@amd.com>
Cc: <amd-gfx@lists.freedesktop.org>, <linux-pci@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
Yifan Zhang <yifan1.zhang@amd.com>
Subject: [PATCH] PCI: Avoid D3 in rumtime PM for AMD gfx v12 PCIe switch upstream port
Date: Thu, 3 Dec 2026 10:15:08 +0800 [thread overview]
Message-ID: <20261203021508.3231344-1-yifan1.zhang@amd.com> (raw)
Do not put the upstream link on gfx v12 cards to D3 at runtime due to hardware
limitation. It can still runtime suspend, but then stays in D0. System
suspend is not affected and still uses D3.
Signed-off-by: Yifan Zhang <yifan1.zhang@amd.com>
---
drivers/pci/quirks.c | 50 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index b09f27f7846f..5f87606bf7a2 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -2085,6 +2085,56 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x15e0, quirk_ryzen_xhci_d3hot);
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x15e1, quirk_ryzen_xhci_d3hot);
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x1639, quirk_ryzen_xhci_d3hot);
+/*
+ * Do not put the upstream link on gfx v12 cards to D3 at runtime due to hardware
+ * limitation. It can still runtime suspend, but then stays in D0. System
+ * suspend is not affected and still uses D3.
+ *
+ * The switch has the same device ID on all Navi cards, so the affected ones
+ * are identified by the major and minor revision of the port, which are the
+ * upper and lower nibble of the PCI Revision ID.
+ */
+#define AMD_NAVI_SWUS_REV_MAJOR GENMASK(7, 4)
+#define AMD_NAVI_SWUS_REV_MINOR GENMASK(3, 0)
+
+static bool amd_gfx12_swus_no_runtime_d3(struct pci_dev *pdev)
+{
+ u8 major = FIELD_GET(AMD_NAVI_SWUS_REV_MAJOR, pdev->revision);
+ u8 minor = FIELD_GET(AMD_NAVI_SWUS_REV_MINOR, pdev->revision);
+
+ /* gfx v12 sw.us revision id 2.4 - 2.5 */
+ return major == 2 && minor >= 4 && minor <= 5;
+}
+
+/* Only log that the quirk applies, the suspend fixup below handles the flag */
+static void quirk_amd_gfx12_swus_no_d3(struct pci_dev *pdev)
+{
+ if (!amd_gfx12_swus_no_runtime_d3(pdev))
+ return;
+
+ pci_info(pdev, "PCIe switch upstream port (rev %lu.%lu), disabling D3 for runtime PM\n",
+ FIELD_GET(AMD_NAVI_SWUS_REV_MAJOR, pdev->revision),
+ FIELD_GET(AMD_NAVI_SWUS_REV_MINOR, pdev->revision));
+}
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, 0x1478, quirk_amd_gfx12_swus_no_d3);
+
+/*
+ * pci_fixup_suspend runs before the PCI core selects the power state, for
+ * runtime suspend as well as for system suspend. Keep the port out of D3
+ * only for the former.
+ */
+static void quirk_amd_gfx12_swus_suspend(struct pci_dev *pdev)
+{
+ if (!amd_gfx12_swus_no_runtime_d3(pdev))
+ return;
+
+ if (pm_suspend_in_progress())
+ pdev->dev_flags &= ~PCI_DEV_FLAGS_NO_D3;
+ else
+ pdev->dev_flags |= PCI_DEV_FLAGS_NO_D3;
+}
+DECLARE_PCI_FIXUP_SUSPEND(PCI_VENDOR_ID_ATI, 0x1478, quirk_amd_gfx12_swus_suspend);
+
#ifdef CONFIG_X86_IO_APIC
static int dmi_disable_ioapicreroute(const struct dmi_system_id *d)
{
--
2.53.0
next reply other threads:[~2026-12-03 2:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 2:15 Yifan Zhang [this message]
2026-12-05 0:36 ` Deucher, Alexander
2026-12-05 17:28 ` Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203021508.3231344-1-yifan1.zhang@amd.com \
--to=yifan1.zhang@amd.com \
--cc=Alexander.Deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=bhelgaas@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®