All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Yifan Zhang <yifan1.zhang@amd.com>
Cc: bhelgaas@google.com, Alexander.Deucher@amd.com,
	amd-gfx@lists.freedesktop.org, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI: Avoid D3 in rumtime PM for AMD gfx v12 PCIe switch upstream port
Date: Sat, 5 Dec 2026 11:28:35 -0600	[thread overview]
Message-ID: <20261205172835.GA974792@bhelgaas> (raw)
In-Reply-To: <20261203021508.3231344-1-yifan1.zhang@amd.com>

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@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.

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
> 

      parent reply	other threads:[~2026-12-05 17:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  2:15 [PATCH] PCI: Avoid D3 in rumtime PM for AMD gfx v12 PCIe switch upstream port Yifan Zhang
2026-12-03  2:43 ` sashiko-bot
2026-12-05  0:36 ` Deucher, Alexander
2026-12-05 17:28 ` Bjorn Helgaas [this message]

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=20261205172835.GA974792@bhelgaas \
    --to=helgaas@kernel.org \
    --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 \
    --cc=yifan1.zhang@amd.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.