Skip to content

Commit da9f215

Browse files
committed
PCI: PM: Avoid forcing PCI_D0 for wakeup reasons inconsistently
It is inconsistent to return PCI_D0 from pci_target_state() instead of the original target state if 'wakeup' is true and the device cannot signal PME from D0. This only happens when the device cannot signal PME from the original target state and any shallower power states (including D0) and that case is effectively equivalent to the one in which PME singaling is not supported at all. Since the original target state is returned in the latter case, make the function do that in the former one too. Link: https://lore.kernel.org/linux-pm/3149540.aeNJFYEL58@kreacher/ Fixes: 666ff6f ("PCI/PM: Avoid using device_may_wakeup() for runtime PM") Reported-by: Mika Westerberg <[email protected]> Reported-by: Utkarsh H Patel <[email protected]> Reported-by: Koba Ko <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Mika Westerberg <[email protected]> Tested-by: Mika Westerberg <[email protected]>
1 parent 14858dc commit da9f215

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

drivers/pci/pci.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2595,16 +2595,20 @@ static pci_power_t pci_target_state(struct pci_dev *dev, bool wakeup)
25952595
if (dev->current_state == PCI_D3cold)
25962596
target_state = PCI_D3cold;
25972597

2598-
if (wakeup) {
2598+
if (wakeup && dev->pme_support) {
2599+
pci_power_t state = target_state;
2600+
25992601
/*
26002602
* Find the deepest state from which the device can generate
26012603
* PME#.
26022604
*/
2603-
if (dev->pme_support) {
2604-
while (target_state
2605-
&& !(dev->pme_support & (1 << target_state)))
2606-
target_state--;
2607-
}
2605+
while (state && !(dev->pme_support & (1 << state)))
2606+
state--;
2607+
2608+
if (state)
2609+
return state;
2610+
else if (dev->pme_support & 1)
2611+
return PCI_D0;
26082612
}
26092613

26102614
return target_state;

0 commit comments

Comments
 (0)