From: Bjorn Helgaas <helgaas@kernel.org>
To: sashiko-reviews@lists.linux.dev
Cc: linux-pci@vger.kernel.org,
"Rafael J . Wysocki" <rafael@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>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
linux-kernel@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>
Subject: Re: [PATCH v1] PCI: Wait for device readiness after D3hot -> D0uninitialized transition
Date: Thu, 14 May 2026 16:38:11 -0500 [thread overview]
Message-ID: <20260514213811.GA434353@bhelgaas> (raw)
In-Reply-To: <20260514200625.C6877C2BCB3@smtp.kernel.org>
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;
return -EIO;
}
}
} else if (state == PCI_D2) {
udelay(PCI_PM_D2_DELAY);
}
> > + } else if (state == PCI_D2) {
> > udelay(PCI_PM_D2_DELAY);
> > + }
> >
> > end:
> > dev->current_state = PCI_D0;
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260514153124.404060-1-bhelgaas@google.com?part=1
next parent reply other threads:[~2026-05-14 21:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260514200625.C6877C2BCB3@smtp.kernel.org>
2026-05-14 21:38 ` Bjorn Helgaas [this message]
2026-05-14 15:31 [PATCH v1] PCI: Wait for device readiness after D3hot -> D0uninitialized transition 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=20260514213811.GA434353@bhelgaas \
--to=helgaas@kernel.org \
--cc=alex@shazbot.org \
--cc=bhelgaas@google.com \
--cc=echanude@redhat.com \
--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=mika.westerberg@linux.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