Re: [PATCH v2] PCI/PM: Avoid suspending the device with errors
From: Raag Jadav
Date: Sat Apr 26 2025 - 15:24:25 EST
On Thu, Apr 24, 2025 at 12:59:55PM +0200, Rafael J. Wysocki wrote:
> On Thu, Apr 24, 2025 at 7:12 AM Raag Jadav <raag.jadav@xxxxxxxxx> wrote:
> >
> > On Tue, Apr 22, 2025 at 02:45:37PM -0500, Bjorn Helgaas wrote:
> > > On Tue, Apr 22, 2025 at 07:23:41PM +0530, Raag Jadav wrote:
> > > > If an error is triggered before or during system suspend, any bus level
> > > > power state transition will result in unpredictable behaviour by the
> > > > device with failed recovery. Avoid suspending such a device and leave
> > > > it in its existing power state.
> > > >
> > > > This only covers the devices that rely on PCI core PM for their power
> > > > state transition.
> > > >
> > > > Signed-off-by: Raag Jadav <raag.jadav@xxxxxxxxx>
> > > > ---
> > > >
> > > > v2: Synchronize AER handling with PCI PM (Rafael)
> > > >
> > > > More discussion on [1].
> > > > [1] https://lore.kernel.org/all/CAJZ5v0g-aJXfVH+Uc=9eRPuW08t-6PwzdyMXsC6FZRKYJtY03Q@xxxxxxxxxxxxxx/
> > >
> > > Thanks for the pointer, but the commit log for this patch needs to be
> > > complete in itself. "Unpredictable behavior" is kind of hand-wavy and
> > > doesn't really help understand the problem.
> > >
> > > > drivers/pci/pci-driver.c | 3 ++-
> > > > drivers/pci/pcie/aer.c | 11 +++++++++++
> > > > include/linux/aer.h | 2 ++
> > > > 3 files changed, 15 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
> > > > index f57ea36d125d..289a1fa7cb2d 100644
> > > > --- a/drivers/pci/pci-driver.c
> > > > +++ b/drivers/pci/pci-driver.c
> > > > @@ -884,7 +884,8 @@ static int pci_pm_suspend_noirq(struct device *dev)
> > > > }
> > > > }
> > > >
> > > > - if (!pci_dev->state_saved) {
> > > > + /* Avoid suspending the device with errors */
> > > > + if (!pci_aer_in_progress(pci_dev) && !pci_dev->state_saved) {
> > >
> > > This looks potentially racy, since hardware can set bits in
> > > PCI_EXP_DEVSTA at any time.
> >
> > Which is why it's placed in ->suspend_noirq() callback. Can it still race?
>
> With the hardware? Yes.
Any thoughts on potential side effects and how to address them?
Raag