All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: linux-pci@vger.kernel.org, bhelgaas@google.com,
	linux-kernel@vger.kernel.org, eric.auger@redhat.com,
	mika.westerberg@linux.intel.com, rafael.j.wysocki@intel.com,
	Sanath.S@amd.com
Subject: Re: [PATCH v2 2/2] PCI: Fix runtime PM race with PME polling
Date: Tue, 23 Jan 2024 17:12:39 +0100	[thread overview]
Message-ID: <20240123161239.GA1386@wunner.de> (raw)
In-Reply-To: <20240123085521.07e2b978.alex.williamson@redhat.com>

On Tue, Jan 23, 2024 at 08:55:21AM -0700, Alex Williamson wrote:
> On Tue, 23 Jan 2024 11:45:19 +0100 Lukas Wunner <lukas@wunner.de> wrote:
> > If the device is RPM_SUSPENDING, why immediately resume it for polling?
> > It's sufficient to poll it the next time around, i.e. 1 second later.
> > 
> > Likewise, if it's already RPM_RESUMING or RPM_ACTIVE anyway, no need
> > to poll PME.
> 
> I'm clearly not an expert on PME, but this is not obvious to me and
> before the commit that went in through this thread, PME wakeup was
> triggered regardless of the PM state.  I was trying to restore the
> behavior of not requiring a specific PM state other than deferring
> polling across transition states.

There are broken devices which are incapable of signaling PME.
As a workaround, the kernel polls these devices once per second.
The first time the device signals PME, the kernel stops polling
that particular device because PME is clearly working.

So this is just a best-effort way to support PME for broken devices.
If it takes a little longer to detect that PME was signaled, it's not
a big deal.


> The issue I'm trying to address is that config space of the device can
> become inaccessible while calling pci_pme_wakeup() on it, causing a
> system fault on some hardware.  So a gratuitous pci_pme_wakeup() can be
> detrimental.
> 
> We require the device config space to remain accessible, therefore the
> instantaneous test against D3cold and that the parent bridge is in D0
> is not sufficient.  I see traces where the parent bridge is in D0, but
> the PM state is RPM_SUSPENDING and the endpoint device transitions to
> D3cold while we're executing pci_pme_wakeup().

We have pci_config_pm_runtime_{get,put}() helpers to ensure the parent
of a device is in D0 so that the device's config space is accessible.
So you may need to use that in pci_pme_wakeup().

Thanks,

Lukas

  reply	other threads:[~2024-01-23 16:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-03 17:12 [PATCH v2 0/2] PCI: Protect VPD and PME accesses from power management Alex Williamson
2023-08-03 17:12 ` [PATCH v2 1/2] PCI/VPD: Add runtime power management to sysfs interface Alex Williamson
2023-08-10 15:59   ` Bjorn Helgaas
2023-08-10 16:26     ` Alex Williamson
2023-08-11 19:25   ` Bjorn Helgaas
2023-08-11 19:56     ` Alex Williamson
2023-08-03 17:12 ` [PATCH v2 2/2] PCI: Fix runtime PM race with PME polling Alex Williamson
2024-01-18 18:50   ` Alex Williamson
2024-01-22 22:17     ` Lukas Wunner
2024-01-22 22:50       ` Alex Williamson
2024-01-23  4:46         ` Alex Williamson
2024-01-23  4:48           ` Sanath S
2024-01-23 10:45         ` Lukas Wunner
2024-01-23 15:55           ` Alex Williamson
2024-01-23 16:12             ` Lukas Wunner [this message]
2024-01-23 16:47               ` Alex Williamson
2023-08-10 18:29 ` [PATCH v2 0/2] PCI: Protect VPD and PME accesses from power management Bjorn Helgaas
2023-08-10 18:54   ` Alex Williamson

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=20240123161239.GA1386@wunner.de \
    --to=lukas@wunner.de \
    --cc=Sanath.S@amd.com \
    --cc=alex.williamson@redhat.com \
    --cc=bhelgaas@google.com \
    --cc=eric.auger@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@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 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.