* Re: [PATCH v1] PCI: Wait for device readiness after D3hot -> D0uninitialized transition
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 12:46 ` Lukas Wunner
2 siblings, 0 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2026-05-15 11:26 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: sashiko-reviews, linux-pci, Rafael J . Wysocki, Lukas Wunner,
Marco Nenciarini, Michal Winiarski, Ilpo Jarvinen, Eric Chanudet,
Jean Guyader, Alex Williamson, Sinan Kaya, Mario Limonciello,
Mika Westerberg, linux-kernel, Bjorn Helgaas
On Thu, May 14, 2026 at 11:38 PM Bjorn Helgaas <helgaas@kernel.org> 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;
> return -EIO;
> }
> }
> } else if (state == PCI_D2) {
> udelay(PCI_PM_D2_DELAY);
> }
This looks reasonable to me, thanks!
> > > + } 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
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v1] PCI: Wait for device readiness after D3hot -> D0uninitialized transition
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:46 ` Lukas Wunner
2 siblings, 1 reply; 8+ messages in thread
From: Mika Westerberg @ 2026-05-15 11:41 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: sashiko-reviews, linux-pci, Rafael J . Wysocki, Lukas Wunner,
Marco Nenciarini, Michal Winiarski, Ilpo Jarvinen, Eric Chanudet,
Jean Guyader, Alex Williamson, Sinan Kaya, Mario Limonciello,
linux-kernel, Bjorn Helgaas
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?
> 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
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v1] PCI: Wait for device readiness after D3hot -> D0uninitialized transition
2026-05-15 11:41 ` Mika Westerberg
@ 2026-05-15 11:57 ` Rafael J. Wysocki
2026-05-15 12:15 ` Mika Westerberg
0 siblings, 1 reply; 8+ messages in thread
From: Rafael J. Wysocki @ 2026-05-15 11:57 UTC (permalink / raw)
To: Mika Westerberg
Cc: Bjorn Helgaas, sashiko-reviews, linux-pci, Rafael J . Wysocki,
Lukas Wunner, Marco Nenciarini, Michal Winiarski, Ilpo Jarvinen,
Eric Chanudet, Jean Guyader, Alex Williamson, Sinan Kaya,
Mario Limonciello, linux-kernel, Bjorn Helgaas
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.
> > 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
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v1] PCI: Wait for device readiness after D3hot -> D0uninitialized transition
2026-05-15 11:57 ` Rafael J. Wysocki
@ 2026-05-15 12:15 ` Mika Westerberg
0 siblings, 0 replies; 8+ messages in thread
From: Mika Westerberg @ 2026-05-15 12:15 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Bjorn Helgaas, sashiko-reviews, linux-pci, Lukas Wunner,
Marco Nenciarini, Michal Winiarski, Ilpo Jarvinen, Eric Chanudet,
Jean Guyader, Alex Williamson, Sinan Kaya, Mario Limonciello,
linux-kernel, Bjorn Helgaas
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1] PCI: Wait for device readiness after D3hot -> D0uninitialized transition
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 12:46 ` Lukas Wunner
2 siblings, 0 replies; 8+ messages in thread
From: Lukas Wunner @ 2026-05-15 12:46 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: sashiko-reviews, linux-pci, Rafael J . Wysocki, Marco Nenciarini,
Michal Winiarski, Ilpo Jarvinen, Eric Chanudet, Jean Guyader,
Alex Williamson, Sinan Kaya, Mario Limonciello, Mika Westerberg,
linux-kernel, Bjorn Helgaas
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:
> > > + 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;
> }
pci_dev_wait() already emits a warning message on timeout, so the
additional pci_err() is probably not needed. Otherwise the user
would see duplicate messages, i.e.:
pci SSSS:BB:DD.F: not ready 60000ms after power up D3hot->D0uninitialized
pci SSSS:BB:DD.F: Not ready after soft reset
Thanks,
Lukas
^ permalink raw reply [flat|nested] 8+ messages in thread