PM: sleep: core: Rework the power.may_skip_resume handling
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sat, 18 Apr 2020 16:52:19 +0000 (18:52 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 24 Apr 2020 19:31:28 +0000 (21:31 +0200)
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 <stern@rowland.harvard.edu>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/acpi/device_pm.c
drivers/base/power/main.c
drivers/pci/pci-driver.c

index 399684085f85313e344caa8b49fb5307c350b8cb..1b02d7dc7d34ccd221767d2ce46b9334468f631d 100644 (file)
@@ -1100,10 +1100,8 @@ int acpi_subsys_suspend_noirq(struct device *dev)
 {
        int ret;
 
-       if (dev_pm_smart_suspend_and_suspended(dev)) {
-               dev->power.may_skip_resume = true;
+       if (dev_pm_smart_suspend_and_suspended(dev))
                return 0;
-       }
 
        ret = pm_generic_suspend_noirq(dev);
        if (ret)
@@ -1116,8 +1114,8 @@ int acpi_subsys_suspend_noirq(struct device *dev)
         * acpi_subsys_complete() to take care of fixing up the device's state
         * anyway, if need be.
         */
-       dev->power.may_skip_resume = device_may_wakeup(dev) ||
-                                       !device_can_wakeup(dev);
+       if (device_can_wakeup(dev) && !device_may_wakeup(dev))
+               dev->power.may_skip_resume = false;
 
        return 0;
 }
index 25b0302188d8fabf2d7596c11aad6d0e095baa98..5adf0be6aa470bafa1b04a615cac5fc4d5261a66 100644 (file)
@@ -1415,14 +1415,8 @@ static int __device_suspend_late(struct device *dev, pm_message_t state, bool as
        if (callback)
                goto Run;
 
-       if (dev_pm_smart_suspend_and_suspended(dev)) {
-               /*
-                * In principle, the resume of the device may be skippend if it
-                * remains in runtime suspend at this point.
-                */
-               dev->power.may_skip_resume = true;
+       if (dev_pm_smart_suspend_and_suspended(dev))
                goto Skip;
-       }
 
        if (dev->driver && dev->driver->pm) {
                info = "late driver ";
@@ -1647,7 +1641,7 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
                dev->power.direct_complete = false;
        }
 
-       dev->power.may_skip_resume = false;
+       dev->power.may_skip_resume = true;
        dev->power.must_resume = false;
 
        dpm_watchdog_set(&wd, dev);
index 685fbf0449111927bd97247c548478440d65d5ca..ce220b1987dfc6326e988e17efe977aaee758bae 100644 (file)
@@ -789,10 +789,8 @@ static int pci_pm_suspend_noirq(struct device *dev)
        struct pci_dev *pci_dev = to_pci_dev(dev);
        const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
 
-       if (dev_pm_smart_suspend_and_suspended(dev)) {
-               dev->power.may_skip_resume = true;
+       if (dev_pm_smart_suspend_and_suspended(dev))
                return 0;
-       }
 
        if (pci_has_legacy_pm_support(pci_dev))
                return pci_legacy_suspend_late(dev, PMSG_SUSPEND);
@@ -880,8 +878,8 @@ Fixup:
         * pci_pm_complete() to take care of fixing up the device's state
         * anyway, if need be.
         */
-       dev->power.may_skip_resume = device_may_wakeup(dev) ||
-                                       !device_can_wakeup(dev);
+       if (device_can_wakeup(dev) && !device_may_wakeup(dev))
+               dev->power.may_skip_resume = false;
 
        return 0;
 }