aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/base/power/main.c5
-rw-r--r--kernel/power/suspend.c19
2 files changed, 21 insertions, 3 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index f64e5b819e5c..ea1732ed7a9d 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1105,6 +1105,11 @@ static int __device_suspend_noirq(struct device *dev, pm_message_t state, bool a
if (async_error)
goto Complete;
+ if (pm_wakeup_pending()) {
+ async_error = -EBUSY;
+ goto Complete;
+ }
+
if (dev->power.syscore || dev->power.direct_complete)
goto Complete;
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 0c61713b6e5c..5cf232795318 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -108,19 +108,32 @@ static void s2idle_loop(void)
{
pm_pr_dbg("suspend-to-idle\n");
- while (!dpm_suspend_noirq(PMSG_SUSPEND)) {
+ for (;;) {
+ int error;
+
+ dpm_noirq_begin();
+
/*
* Suspend-to-idle equals
* frozen processes + suspended devices + idle processors.
* Thus freeze_enter() should be called right after
* 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)
freeze_ops->wake();
- dpm_resume_noirq(PMSG_RESUME);
+ dpm_noirq_end();
+
if (freeze_ops && freeze_ops->sync)
freeze_ops->sync();