Commit 9a3ebe35 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

PM / sleep: Check pm_wakeup_pending() in __device_suspend_noirq()

Restore the pm_wakeup_pending() check in __device_suspend_noirq()
removed by commit eed4d47e (ACPI / sleep: Ignore spurious SCI
wakeups from suspend-to-idle) as that allows the function to return
earlier if there's a wakeup event pending already (so that it may
spend less time on carrying out operations that will be reversed
shortly anyway) and rework the main suspend-to-idle loop to take
that optimization into account.
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 48059c09
...@@ -1105,6 +1105,11 @@ static int __device_suspend_noirq(struct device *dev, pm_message_t state, bool a ...@@ -1105,6 +1105,11 @@ static int __device_suspend_noirq(struct device *dev, pm_message_t state, bool a
if (async_error) if (async_error)
goto Complete; goto Complete;
if (pm_wakeup_pending()) {
async_error = -EBUSY;
goto Complete;
}
if (dev->power.syscore || dev->power.direct_complete) if (dev->power.syscore || dev->power.direct_complete)
goto Complete; goto Complete;
......
...@@ -108,19 +108,32 @@ static void s2idle_loop(void) ...@@ -108,19 +108,32 @@ static void s2idle_loop(void)
{ {
pm_pr_dbg("suspend-to-idle\n"); pm_pr_dbg("suspend-to-idle\n");
while (!dpm_suspend_noirq(PMSG_SUSPEND)) { for (;;) {
int error;
dpm_noirq_begin();
/* /*
* Suspend-to-idle equals * Suspend-to-idle equals
* frozen processes + suspended devices + idle processors. * frozen processes + suspended devices + idle processors.
* Thus freeze_enter() should be called right after * Thus freeze_enter() should be called right after
* all devices have been suspended. * all devices have been suspended.
*/ */
freeze_enter(); error = dpm_noirq_suspend_devices(PMSG_SUSPEND);
if (!error)
freeze_enter();
dpm_noirq_resume_devices(PMSG_RESUME);
if (error && (error != -EBUSY || !pm_wakeup_pending())) {
dpm_noirq_end();
break;
}
if (freeze_ops && freeze_ops->wake) if (freeze_ops && freeze_ops->wake)
freeze_ops->wake(); freeze_ops->wake();
dpm_resume_noirq(PMSG_RESUME); dpm_noirq_end();
if (freeze_ops && freeze_ops->sync) if (freeze_ops && freeze_ops->sync)
freeze_ops->sync(); freeze_ops->sync();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment