All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: "David E. Box" <david.e.box@linux.intel.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	Len Brown <len.brown@intel.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Linux PCI <linux-pci@vger.kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] PCI: Disable PTM during suspend on Intel PCI bridges
Date: Wed, 7 Oct 2020 18:53:16 +0200	[thread overview]
Message-ID: <CAJZ5v0gRph3UMffWqUVqTnDE149Ai-SbzmhjzZU1x=QOzAZeZA@mail.gmail.com> (raw)
In-Reply-To: <20201007164851.1218-1-david.e.box@linux.intel.com>

On Wed, Oct 7, 2020 at 6:49 PM David E. Box <david.e.box@linux.intel.com> wrote:
>
> On Intel Platform Controller Hubs (PCH) since Cannon Lake, the Precision
> Time Measurement (PTM) capability can prevent PCIe root ports from power
> gating during suspend-to-idle, causing increased power consumption on
> systems that suspend using Low Power S0 Idle [1]. The issue is yet to be
> root caused but believed to be coming from a race condition in the suspend
> flow as the incidence rate varies for different platforms on Linux but the
> issue does not occur at all in other operating systems. For now, disable
> the feature on suspend on all Intel root ports and enable again on resume.

IMV it should also be noted that there is no particular reason why PTM
would need to be enabled while the whole system is suspended.  At
least it doesn't seem to be particularly useful in that state.

> Link: https://www.uefi.org/sites/default/files/resources/Intel_ACPI_Low_Power_S0_Idle.pdf
> Bug: https://bugzilla.kernel.org/show_bug.cgi?id=209361
> Tested-by: Len Brown <len.brown@intel.com>
> Signed-off-by: David E. Box <david.e.box@linux.intel.com>
> ---
>  drivers/pci/quirks.c | 57 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 57 insertions(+)
>
> diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
> index bdf9b52567e0..e82b1f60c7a1 100644
> --- a/drivers/pci/quirks.c
> +++ b/drivers/pci/quirks.c
> @@ -5632,3 +5632,60 @@ static void apex_pci_fixup_class(struct pci_dev *pdev)
>  }
>  DECLARE_PCI_FIXUP_CLASS_HEADER(0x1ac1, 0x089a,
>                                PCI_CLASS_NOT_DEFINED, 8, apex_pci_fixup_class);
> +
> +#ifdef CONFIG_PCIE_PTM
> +/*
> + * On Intel Platform Controller Hubs (PCH) since Cannon Lake, the Precision
> + * Time Measurement (PTM) capability can prevent the PCIe root port from
> + * power gating during suspend-to-idle, causing increased power consumption.
> + * So disable the feature on suspend on all Intel root ports and enable
> + * again on resume.
> + */
> +static void quirk_intel_ptm_disable_suspend(struct pci_dev *dev)
> +{
> +       int pos;
> +       u32 ctrl;
> +
> +       if (!(dev->ptm_enabled && dev->ptm_root))
> +               return;
> +
> +       pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_PTM);
> +       if (!pos)
> +               return;
> +
> +       pci_dbg(dev, "quirk: disabling PTM\n");
> +
> +       dev->ptm_enabled = 0;
> +       dev->ptm_root = 0;
> +
> +       pci_read_config_dword(dev, pos + PCI_PTM_CTRL, &ctrl);
> +       ctrl &= ~(PCI_PTM_CTRL_ENABLE | PCI_PTM_CTRL_ROOT);
> +       pci_write_config_dword(dev, pos + PCI_PTM_CTRL, ctrl);
> +}
> +
> +static void quirk_intel_ptm_enable_resume(struct pci_dev *dev)
> +{
> +       int pos;
> +       u32 ctrl;
> +
> +       pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_PTM);
> +       if (!pos)
> +               return;
> +
> +       pci_dbg(dev, "quirk: re-enabling PTM\n");
> +
> +       pci_read_config_dword(dev, pos + PCI_PTM_CTRL, &ctrl);
> +       ctrl |= PCI_PTM_CTRL_ENABLE | PCI_PTM_CTRL_ROOT;
> +       pci_write_config_dword(dev, pos + PCI_PTM_CTRL, ctrl);
> +
> +       dev->ptm_enabled = 1;
> +       dev->ptm_root = 1;
> +}
> +
> +DECLARE_PCI_FIXUP_CLASS_SUSPEND(PCI_VENDOR_ID_INTEL, PCI_ANY_ID,
> +                               PCI_CLASS_BRIDGE_PCI, 8,
> +                               quirk_intel_ptm_disable_suspend)
> +DECLARE_PCI_FIXUP_CLASS_RESUME(PCI_VENDOR_ID_INTEL, PCI_ANY_ID,
> +                              PCI_CLASS_BRIDGE_PCI, 8,
> +                              quirk_intel_ptm_enable_resume)
> +#endif
> --
> 2.20.1
>

  reply	other threads:[~2020-10-07 16:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-07 16:48 [PATCH] PCI: Disable PTM during suspend on Intel PCI bridges David E. Box
2020-10-07 16:53 ` Rafael J. Wysocki [this message]
2020-10-07 17:10   ` Bjorn Helgaas
2020-11-16 17:53     ` Rafael J. Wysocki
2020-11-16 19:23       ` Bjorn Helgaas
2020-11-16 20:58         ` David E. Box
2020-11-17 12:54           ` Rafael J. Wysocki

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='CAJZ5v0gRph3UMffWqUVqTnDE149Ai-SbzmhjzZU1x=QOzAZeZA@mail.gmail.com' \
    --to=rafael@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=david.e.box@linux.intel.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@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 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.