Skip to content

Commit 0fe8a1b

Browse files
committed
PM: sleep: core: Rework the power.may_skip_resume handling
Because the power.may_skip_resume device status bit is taken into account in combination with the DPM_FLAG_LEAVE_SUSPENDED driver flag, it can be set to 'true' for all devices in the "suspend" phase of a suspend-resume cycle, so do that. Then, neither the PM core nor the middle-layer (sybsystem) code handling it needs to set it to 'true' any more and it just has to be cleared if there is a reason to avoid skipping the "noirq" and "early" resume callbacks provided by the driver, so update the code in question accordingly. Suggested-by: Alan Stern <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]> Acked-by: Alan Stern <[email protected]> Acked-by: Bjorn Helgaas <[email protected]>
1 parent 6e176bf commit 0fe8a1b

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

drivers/acpi/device_pm.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,10 +1100,8 @@ int acpi_subsys_suspend_noirq(struct device *dev)
11001100
{
11011101
int ret;
11021102

1103-
if (dev_pm_smart_suspend_and_suspended(dev)) {
1104-
dev->power.may_skip_resume = true;
1103+
if (dev_pm_smart_suspend_and_suspended(dev))
11051104
return 0;
1106-
}
11071105

11081106
ret = pm_generic_suspend_noirq(dev);
11091107
if (ret)
@@ -1116,8 +1114,8 @@ int acpi_subsys_suspend_noirq(struct device *dev)
11161114
* acpi_subsys_complete() to take care of fixing up the device's state
11171115
* anyway, if need be.
11181116
*/
1119-
dev->power.may_skip_resume = device_may_wakeup(dev) ||
1120-
!device_can_wakeup(dev);
1117+
if (device_can_wakeup(dev) && !device_may_wakeup(dev))
1118+
dev->power.may_skip_resume = false;
11211119

11221120
return 0;
11231121
}

drivers/base/power/main.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,14 +1415,8 @@ static int __device_suspend_late(struct device *dev, pm_message_t state, bool as
14151415
if (callback)
14161416
goto Run;
14171417

1418-
if (dev_pm_smart_suspend_and_suspended(dev)) {
1419-
/*
1420-
* In principle, the resume of the device may be skippend if it
1421-
* remains in runtime suspend at this point.
1422-
*/
1423-
dev->power.may_skip_resume = true;
1418+
if (dev_pm_smart_suspend_and_suspended(dev))
14241419
goto Skip;
1425-
}
14261420

14271421
if (dev->driver && dev->driver->pm) {
14281422
info = "late driver ";
@@ -1647,7 +1641,7 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
16471641
dev->power.direct_complete = false;
16481642
}
16491643

1650-
dev->power.may_skip_resume = false;
1644+
dev->power.may_skip_resume = true;
16511645
dev->power.must_resume = false;
16521646

16531647
dpm_watchdog_set(&wd, dev);

drivers/pci/pci-driver.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -789,10 +789,8 @@ static int pci_pm_suspend_noirq(struct device *dev)
789789
struct pci_dev *pci_dev = to_pci_dev(dev);
790790
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
791791

792-
if (dev_pm_smart_suspend_and_suspended(dev)) {
793-
dev->power.may_skip_resume = true;
792+
if (dev_pm_smart_suspend_and_suspended(dev))
794793
return 0;
795-
}
796794

797795
if (pci_has_legacy_pm_support(pci_dev))
798796
return pci_legacy_suspend_late(dev, PMSG_SUSPEND);
@@ -880,8 +878,8 @@ static int pci_pm_suspend_noirq(struct device *dev)
880878
* pci_pm_complete() to take care of fixing up the device's state
881879
* anyway, if need be.
882880
*/
883-
dev->power.may_skip_resume = device_may_wakeup(dev) ||
884-
!device_can_wakeup(dev);
881+
if (device_can_wakeup(dev) && !device_may_wakeup(dev))
882+
dev->power.may_skip_resume = false;
885883

886884
return 0;
887885
}

0 commit comments

Comments
 (0)