PCI: Wait for device readiness after D3hot -> D0uninitialized transition
PATCH 1/1 PCI: Wait for device readiness after D3hot -> D0uninitialized transition
For a device that advertises No_Soft_Reset == 0, a transition from D3hot to D0uninitialized is a soft reset, and the resulting internal device state is undefined.
A transition from D3hot to D0uninitialized requires a minimum delay of 10 msec before accessing the device, but after that delay, the device is permitted to respond to config requests with RRS completion status if it needs more time to initialize (PCIe r7.0, sec 2.3.1).
Call pci_dev_wait() after pci_power_up() performs a D3hot->D0uninitialized transition to ensure the device is ready to accept config accesses, as is done after the similar transition in pci_pm_reset().
If the device is already ready, this is essentially a no-op except for one additional config read.
--- drivers/pci/pci.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/pci/pci.c +16 -2
@@ -1301,6 +1301,16 @@ int pci_power_up(struct pci_dev *dev)pci_power_t state;u16 pmcsr; +/* +* When setting power state to D0, platform_pci_set_power_state() +* ensures main power is on. If it puts the device in D0, it also +* completes any required delays after the transition; if it leaves +* the device in D1, D2, or D3hot, we use the PM Capability to +* transition to D0. +* +* In all cases, the device is either Configuration-Ready or +* inaccessible upon return. +*/ platform_pci_set_power_state (dev,PCI_D0 );if (!dev->pm_cap) {
@@ -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 ); + }else if (state ==PCI_D2 ) {udelay (PCI_PM_D2_DELAY ); + } end: dev->current_state =PCI_D0 ;
Signature · 1 line
2.51.0
Quoted 9 lines · Bjorn Helgaas
For a device that advertises
No_Soft_Reset== 0, a transition from D3hot to D0uninitialized is a soft reset, and the resulting internal device state is undefined.A transition from D3hot to D0uninitialized requires a minimum delay of 10 msec before accessing the device, but after that delay, the device is permitted to respond to config requests with RRS completion status if it needs more time to initialize (PCIe r7.0, sec 2.3.1).
Quoted 8 lines
Call
pci_dev_wait()afterpci_power_up()performs aD3hot->D0uninitializedtransition to ensure the device is ready to accept config accesses, as is done after the similar transition inpci_pm_reset().If the device is already ready, this is essentially a no-op except for one additional config read.
Signed-off-by Bjorn Helgaas <[email protected]>
BTW -
This reminds me of an attempt I had at solving a similar issue a few years back. It would be a nice side effect if this actually solves that
issue too.
https://lore.kernel.org/linux-pci/[email protected]/
Quoted 42 lines
--- drivers/pci/pci.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)drivers/pci/pci.c +16
-2@@ -1301,6 +1301,16 @@ int pci_power_up(struct pci_dev *dev)pci_power_t state;u16 pmcsr; +/* +* When setting power state to D0, platform_pci_set_power_state() +* ensures main power is on. If it puts the device in D0, it also +* completes any required delays after the transition; if it leaves +* the device in D1, D2, or D3hot, we use the PM Capability to +* transition to D0. +* +* In all cases, the device is either Configuration-Ready or +* inaccessible upon return. +*/ platform_pci_set_power_state (dev,PCI_D0 );if (!dev->pm_cap) {@@ -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 ); + }else if (state ==PCI_D2 ) {udelay (PCI_PM_D2_DELAY ); + } end: dev->current_state =PCI_D0 ;
[email protected]
AI reviewThank 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 --
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 <[email protected]>
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.
Quoted 4 lines
drivers/pci/pci.c +0
-0
[ ... ]
drivers/pci/pci.c int pci_power_up(struct pci_dev *dev) · line 1358
Quoted 11 lines
drivers/pci/pci.c +4
-2@@ -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?
Quoted 6 lines
drivers/pci/pci.c +2
-0+ }else if (state ==PCI_D2 ) {udelay (PCI_PM_D2_DELAY ); + } end: dev->current_state =PCI_D0 ;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 36 lines · On Thu, May 14, 2026 at 08:06:25PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Ignored return value ofpci_dev_wait()masks hardware readiness timeouts --commit
606c3a6294de4df52ee7dc27a7792cef6c8f72c4
Author: Bjorn Helgaas <[email protected]>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 withNo_Soft_Reset== 0.Quoted 4 lines
drivers/pci/pci.c +0
-0[ ... ]
drivers/pci/pci.c int pci_power_up(struct pci_dev *dev) · line 1358
Quoted 11 lines
drivers/pci/pci.c +4
-2@@ -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 setsdev->current_state=PCI_D0, and can return success (1 forneed_restore).
Quoted 6 lines
If
pci_power_up()returns success, will callers likepci_back_from_sleep()executepci_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 frompci_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);
}Quoted 9 lines
Quoted 6 lines
drivers/pci/pci.c +2
-0+ }else if (state ==PCI_D2 ) {udelay (PCI_PM_D2_DELAY ); + } end: dev->current_state =PCI_D0 ;Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 47 lines · Bjorn Helgaas
Quoted 36 lines · On Thu, May 14, 2026 at 08:06:25PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Ignored return value ofpci_dev_wait()masks hardware readiness timeouts --commit
606c3a6294de4df52ee7dc27a7792cef6c8f72c4
Author: Bjorn Helgaas <[email protected]>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 withNo_Soft_Reset== 0.Quoted 4 lines
drivers/pci/pci.c +0
-0[ ... ]
drivers/pci/pci.c int pci_power_up(struct pci_dev *dev) · line 1358
Quoted 11 lines
drivers/pci/pci.c +4
-2@@ -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 setsdev->current_state=PCI_D0, and can return success (1 forneed_restore).Quoted 6 lines
If
pci_power_up()returns success, will callers likepci_back_from_sleep()executepci_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 frompci_dev_wait()to prevent this?Good point. I think it should look like this instead:
Quoted 14 lines
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!
Quoted 9 lines
Quoted 9 lines
drivers/pci/pci.c int pci_power_up(struct pci_dev *dev) · line 1364
Quoted 6 lines
drivers/pci/pci.c +2
-0+ }else if (state ==PCI_D2 ) {udelay (PCI_PM_D2_DELAY ); + } end: dev->current_state =PCI_D0 ;--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 46 lines · Bjorn Helgaas
Quoted 36 lines · On Thu, May 14, 2026 at 08:06:25PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Ignored return value ofpci_dev_wait()masks hardware readiness timeouts --commit
606c3a6294de4df52ee7dc27a7792cef6c8f72c4
Author: Bjorn Helgaas <[email protected]>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 withNo_Soft_Reset== 0.Quoted 4 lines
drivers/pci/pci.c +0
-0[ ... ]
drivers/pci/pci.c int pci_power_up(struct pci_dev *dev) · line 1358
Quoted 11 lines
drivers/pci/pci.c +4
-2@@ -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 setsdev->current_state=PCI_D0, and can return success (1 forneed_restore).Quoted 6 lines
If
pci_power_up()returns success, will callers likepci_back_from_sleep()executepci_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 frompci_dev_wait()to prevent this?Good point. I think it should look like this instead:
Quoted 8 lines
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?
Quoted 16 lines
return -EIO; } } } else if (state == PCI_D2) { udelay(PCI_PM_D2_DELAY); }Quoted 9 lines
Quoted 6 lines
drivers/pci/pci.c +2
-0+ }else if (state ==PCI_D2 ) {udelay (PCI_PM_D2_DELAY ); + } end: dev->current_state =PCI_D0 ;Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 57 lines · Mika Westerberg
Quoted 46 lines · Bjorn Helgaas
Quoted 36 lines · On Thu, May 14, 2026 at 08:06:25PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Ignored return value ofpci_dev_wait()masks hardware readiness timeouts --commit
606c3a6294de4df52ee7dc27a7792cef6c8f72c4
Author: Bjorn Helgaas <[email protected]>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 withNo_Soft_Reset== 0.Quoted 4 lines
drivers/pci/pci.c +0
-0[ ... ]
drivers/pci/pci.c int pci_power_up(struct pci_dev *dev) · line 1358
Quoted 11 lines
drivers/pci/pci.c +4
-2@@ -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 setsdev->current_state=PCI_D0, and can return success (1 forneed_restore).Quoted 6 lines
If
pci_power_up()returns success, will callers likepci_back_from_sleep()executepci_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 frompci_dev_wait()to prevent this?Good point. I think it should look like this instead:
Quoted 8 lines
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;
Quoted 1 line
I wonder if
PCI_POWER_ERRORmakes sense here?
Not really, PCI_POWER_ERROR is mostly used by things like "target_state" to indicate that nothing has been selected.
Quoted 16 lines
Quoted 16 lines
return -EIO; } } } else if (state == PCI_D2) { udelay(PCI_PM_D2_DELAY); }Quoted 9 lines
drivers/pci/pci.c int pci_power_up(struct pci_dev *dev) · line 1364
Quoted 6 lines
drivers/pci/pci.c +2
-0+ }else if (state ==PCI_D2 ) {udelay (PCI_PM_D2_DELAY ); + } end: dev->current_state =PCI_D0 ;--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 59 lines · Rafael J. Wysocki
Quoted 57 lines · Mika Westerberg
Quoted 54 lines · Bjorn Helgaas
Quoted 36 lines · On Thu, May 14, 2026 at 08:06:25PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Ignored return value ofpci_dev_wait()masks hardware readiness timeouts --commit
606c3a6294de4df52ee7dc27a7792cef6c8f72c4
Author: Bjorn Helgaas <[email protected]>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 withNo_Soft_Reset== 0.Quoted 4 lines
drivers/pci/pci.c +0
-0[ ... ]
drivers/pci/pci.c int pci_power_up(struct pci_dev *dev) · line 1358
Quoted 11 lines
drivers/pci/pci.c +4
-2@@ -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 setsdev->current_state=PCI_D0, and can return success (1 forneed_restore).Quoted 6 lines
If
pci_power_up()returns success, will callers likepci_back_from_sleep()executepci_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 frompci_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;
Quoted 4 lines
Quoted 1 line
I wonder if
PCI_POWER_ERRORmakes sense here?Not really,
PCI_POWER_ERRORis mostly used by things like "target_state" to indicate that nothing has been selected.
Okay. Thanks.
Quoted 20 lines · Bjorn Helgaas
Quoted 10 lines · On Thu, May 14, 2026 at 08:06:25PM +0000, [email protected] wrote:
drivers/pci/pci.c int pci_power_up(struct pci_dev *dev) · line 1358
Quoted 3 lines
drivers/pci/pci.c +3
-0+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 setsdev->current_state=PCI_D0, and can return success (1 forneed_restore).Quoted 6 lines
If
pci_power_up()returns success, will callers likepci_back_from_sleep()executepci_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 frompci_dev_wait()to prevent this?Good point. I think it should look like this instead:
Quoted 10 lines
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
Quoted 32 lines · Lukas Wunner
Quoted 20 lines · Bjorn Helgaas
Quoted 10 lines · On Thu, May 14, 2026 at 08:06:25PM +0000, [email protected] wrote:
drivers/pci/pci.c int pci_power_up(struct pci_dev *dev) · line 1358
Quoted 3 lines
drivers/pci/pci.c +3
-0+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 setsdev->current_state=PCI_D0, and can return success (1 forneed_restore).Quoted 6 lines
If
pci_power_up()returns success, will callers likepci_back_from_sleep()executepci_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 frompci_dev_wait()to prevent this?Good point. I think it should look like this instead:
Quoted 10 lines
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; }
Quoted 6 lines
pci_dev_wait()already emits a warning message on timeout, so the additionalpci_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->D0uninitializedpci SSSS:BB:DD.F: Not ready after soft reset
True, it is redundant. My thinking was that the other message from pci_power_up() is KERN_ERR, while the one from pci_dev_wait() is only KERN_WARNING.
But maybe that message from pci_dev_wait() should be KERN_ERR instead of KERN_WARNING? As far as that device is concerned, the lack of response does seem like more than just a warning.