From: Lukas Wunner <lukas@wunner.de>
To: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>,
Bjorn Helgaas <bhelgaas@google.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
"open list:PCI SUBSYSTEM" <linux-pci@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>,
Linux PM <linux-pm@vger.kernel.org>
Subject: Re: [PATCH v2] PCI: Check PCIe upstream port for PME support
Date: Fri, 22 Oct 2021 08:53:01 +0200 [thread overview]
Message-ID: <20211022065301.GA17656@wunner.de> (raw)
In-Reply-To: <6289c754-3580-4102-8ff2-666c3cad8da2@intel.com>
On Thu, Oct 21, 2021 at 09:13:29PM +0200, Rafael J. Wysocki wrote:
> On 10/21/2021 8:56 AM, Kai-Heng Feng wrote:
> > On Thu, Aug 12, 2021 at 11:39 PM Kai-Heng Feng <kai.heng.feng@canonical.com> wrote:
> > > Some platforms cannot detect ethernet hotplug once its upstream port is
> > > runtime suspended because PME isn't granted by BIOS _OSC. The issue can
> > > be workarounded by "pcie_ports=native".
> > >
> > > The vendor confirmed that the PME in _OSC is disabled intentionally for
> > > system stability issues on the other OS, so we should also honor the PME
> > > setting here.
> > >
> > > So before marking PME support status for the device, check
> > > PCI_EXP_RTCTL_PMEIE bit to ensure PME interrupt is either enabled by
> > > firmware or OS.
>
> So you basically want to check whether or not the PME interrupts are
> configured on the port?
This platform doesn't grant PME handling to OSPM, but the platform
doesn't handle PME itself either (recognizable by the fact that it
didn't set the PME Interrupt Enable bit in the Root Control Register).
The rationale of the patch is to recognize this situation and rely
on PME polling instead.
That is achieved by assuming no PME support for the device, despite
the device claiming that PME is supported.
(This information should probably be included in the commit message.)
> > > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> > > index aacf575c15cf..4344dc302edd 100644
> > > --- a/drivers/pci/pci.c
> > > +++ b/drivers/pci/pci.c
> > > @@ -2294,6 +2294,32 @@ void pci_pme_wakeup_bus(struct pci_bus *bus)
> > > pci_walk_bus(bus, pci_pme_wakeup, (void *)true);
> > > }
> > >
> > > +#ifdef CONFIG_PCIE_PME
> > > +static bool pci_pcie_port_pme_enabled(struct pci_dev *dev)
> > > +{
> > > + struct pci_dev *bridge = pci_upstream_bridge(dev);
> > > + u16 val;
> > > + int ret;
> > > +
> > > + if (!bridge)
> > > + return true;
> > > +
> > > + if (pci_pcie_type(bridge) != PCI_EXP_TYPE_ROOT_PORT &&
> > > + pci_pcie_type(bridge) != PCI_EXP_TYPE_RC_EC)
> > > + return true;
> > > +
> > > + ret = pcie_capability_read_word(bridge, PCI_EXP_RTCTL, &val);
> > > + if (ret)
> > > + return false;
> > > +
> > > + return val & PCI_EXP_RTCTL_PMEIE;
> > > +}
> > > +#else
> > > +static bool pci_pcie_port_pme_enabled(struct pci_dev *dev)
> > > +{
> > > + return true;
> > > +}
> > > +#endif
> > >
> > > /**
> > > * pci_pme_capable - check the capability of PCI device to generate PME#
> > > @@ -3095,7 +3121,7 @@ void pci_pm_init(struct pci_dev *dev)
> > > }
> > >
> > > pmc &= PCI_PM_CAP_PME_MASK;
> > > - if (pmc) {
> > > + if (pmc && pci_pcie_port_pme_enabled(dev)) {
> > > pci_info(dev, "PME# supported from%s%s%s%s%s\n",
> > > (pmc & PCI_PM_CAP_PME_D0) ? " D0" : "",
> > > (pmc & PCI_PM_CAP_PME_D1) ? " D1" : "",
> > > --
> > > 2.32.0
prev parent reply other threads:[~2021-10-22 7:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-12 15:39 [PATCH v2] PCI: Check PCIe upstream port for PME support Kai-Heng Feng
2021-10-21 6:56 ` Kai-Heng Feng
2021-10-21 19:13 ` Rafael J. Wysocki
2021-10-22 3:04 ` Kai-Heng Feng
2021-10-22 6:53 ` Lukas Wunner [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=20211022065301.GA17656@wunner.de \
--to=lukas@wunner.de \
--cc=bhelgaas@google.com \
--cc=kai.heng.feng@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=rafael.j.wysocki@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox