Re: [PATCH] PCI: Avoid D3 in rumtime PM for AMD gfx v12 PCIe switch upstream port

From: Bjorn Helgaas

Date: Sat Dec 05 2026 - 12:28:44 EST


On Thu, Dec 03, 2026 at 10:15:08AM +0800, Yifan Zhang wrote:
> 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@xxxxxxx>
> ---
> 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.

D3 is a power management state of a device, not of a link. I guess
there's an integrated switch [1002:1478], and we can't put that device
into D3?

Can we say anything more about the hardware limitation? Is there some
published erratum about it that we can reference? What happens if we
*do* put it in D3?

I'm guessing "It can still runtime suspend, but then stays in D0"
basically means runtime suspend won't do anything with this device,
except maybe save the config state in pci_pm_runtime_suspend()?

Wrap this to fit in 80 columns like the rest of the file.

Pick either one or two spaces after period and use it consistently
(also in commit log).

> + *
> + * 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;

I think it's needlessly confusing to negate a function called
"no_runtime_d3".

> + 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
>