The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Bjorn Helgaas <helgaas@kernel.org>,
	sashiko-reviews@lists.linux.dev, linux-pci@vger.kernel.org,
	Lukas Wunner <lukas@wunner.de>,
	Marco Nenciarini <mnencia@kcore.it>,
	Michal Winiarski <michal.winiarski@intel.com>,
	Ilpo Jarvinen <ilpo.jarvinen@linux.intel.com>,
	Eric Chanudet <echanude@redhat.com>,
	Jean Guyader <jean.guyader@gmail.com>,
	Alex Williamson <alex@shazbot.org>, Sinan Kaya <okaya@kernel.org>,
	Mario Limonciello <superm1@kernel.org>,
	linux-kernel@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>
Subject: Re: [PATCH v1] PCI: Wait for device readiness after D3hot -> D0uninitialized transition
Date: Fri, 15 May 2026 14:15:02 +0200	[thread overview]
Message-ID: <20260515121502.GK84797@black.igk.intel.com> (raw)
In-Reply-To: <CAJZ5v0igy2g0zCJrY8wsFiDzVvQUkQH=y6EM1M50rPB-04G3MQ@mail.gmail.com>

On Fri, May 15, 2026 at 01:57:13PM +0200, Rafael J. Wysocki wrote:
> On Fri, May 15, 2026 at 1:41 PM Mika Westerberg
> <mika.westerberg@linux.intel.com> wrote:
> >
> > On Thu, May 14, 2026 at 04:38:11PM -0500, Bjorn Helgaas wrote:
> > > On Thu, May 14, 2026 at 08:06:25PM +0000, sashiko-bot@kernel.org wrote:
> > > > Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> > > > - [High] Ignored return value of `pci_dev_wait()` masks hardware readiness timeouts
> > > > --
> > > >
> > > > commit 606c3a6294de4df52ee7dc27a7792cef6c8f72c4
> > > > Author: Bjorn Helgaas <helgaas@kernel.org>
> > > >
> > > > PCI: Wait for device readiness after D3hot -> D0uninitialized transition
> > > >
> > > > This commit adds a call to pci_dev_wait() after transitioning a device from
> > > > D3hot to D0uninitialized. This ensures the device is ready to accept config
> > > > accesses, especially for devices with No_Soft_Reset == 0.
> > > >
> > > > > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> > > > > index 8f7cfcc000901..9d0fc9fbb76a0 100644
> > > > > --- a/drivers/pci/pci.c
> > > > > +++ b/drivers/pci/pci.c
> > > > [ ... ]
> > > > > @@ -1341,10 +1351,14 @@ int pci_power_up(struct pci_dev *dev)
> > > > >   pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, 0);
> > > > >
> > > > >   /* Mandatory transition delays; see PCI PM 1.2. */
> > > > > - if (state == PCI_D3hot)
> > > > > + if (state == PCI_D3hot) {
> > > > >           pci_dev_d3_sleep(dev);
> > > > > - else if (state == PCI_D2)
> > > > > +         if (!(pmcsr & PCI_PM_CTRL_NO_SOFT_RESET))
> > > > > +                 pci_dev_wait(dev, "power up D3hot->D0uninitialized",
> > > > > +                              PCIE_RESET_READY_POLL_MS);
> > > >
> > > > Is it safe to ignore the return value of pci_dev_wait() here?
> > > >
> > > > If the device times out or disconnects, pci_dev_wait() returns -ENOTTY. By
> > > > ignoring this error, pci_power_up() continues, unconditionally sets
> > > > dev->current_state = PCI_D0, and can return success (1 for need_restore).
> > > >
> > > > If pci_power_up() returns success, will callers like pci_back_from_sleep()
> > > > execute pci_restore_state() against an unresponsive device, which could
> > > > potentially trigger PCIe Master Aborts, AER events, or system crashes?
> > > >
> > > > Should pci_power_up() propagate the error from pci_dev_wait() to prevent
> > > > this?
> > >
> > > Good point.  I think it should look like this instead:
> > >
> > >     if (state == PCI_D3hot) {
> > >             pci_dev_d3_sleep(dev);
> > >             if (!(pmcsr & PCI_PM_CTRL_NO_SOFT_RESET)) {
> > >                     ret = pci_dev_wait(dev, "power up D3hot->D0uninitialized",
> > >                                        PCIE_RESET_READY_POLL_MS);
> > >                     if (ret) {
> > >                             pci_err(dev, "Not ready after soft reset\n");
> > >                             dev->current_state = PCI_D3cold;
> >
> > I wonder if PCI_POWER_ERROR makes sense here?
> 
> Not really, PCI_POWER_ERROR is mostly used by things like
> "target_state" to indicate that nothing has been selected.

Okay. Thanks.

  reply	other threads:[~2026-05-15 12:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260514200625.C6877C2BCB3@smtp.kernel.org>
2026-05-14 21:38 ` [PATCH v1] PCI: Wait for device readiness after D3hot -> D0uninitialized transition Bjorn Helgaas
2026-05-15 11:26   ` Rafael J. Wysocki
2026-05-15 11:41   ` Mika Westerberg
2026-05-15 11:57     ` Rafael J. Wysocki
2026-05-15 12:15       ` Mika Westerberg [this message]
2026-05-15 12:46   ` Lukas Wunner
2026-05-14 15:31 Bjorn Helgaas
2026-05-14 18:52 ` Mario Limonciello

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=20260515121502.GK84797@black.igk.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=alex@shazbot.org \
    --cc=bhelgaas@google.com \
    --cc=echanude@redhat.com \
    --cc=helgaas@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jean.guyader@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=michal.winiarski@intel.com \
    --cc=mnencia@kcore.it \
    --cc=okaya@kernel.org \
    --cc=rafael@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=superm1@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox