PM / Sleep: Look for wakeup events in later stages of device suspend
authorRafael J. Wysocki <rjw@sisk.pl>
Sun, 29 Apr 2012 20:52:19 +0000 (22:52 +0200)
committerRafael J. Wysocki <rjw@sisk.pl>
Tue, 1 May 2012 19:24:50 +0000 (21:24 +0200)
Currently, the device suspend code in drivers/base/power/main.c
only checks if there have been any wakeup events, and therefore the
ongoing system transition to a sleep state should be aborted, during
the first (i.e. "suspend") device suspend phase.  However, wakeup
events may be reported later as well, so it's reasonable to look for
them in the in the subsequent (i.e. "late suspend" and "suspend
noirq") phases.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/power/main.c

index b462c0e341cbf6721fc2ab1dc7f59314f344f625..e0fb5b0435a350abaa5a23c30e76f4e5d691001a 100644 (file)
@@ -889,6 +889,11 @@ static int dpm_suspend_noirq(pm_message_t state)
                if (!list_empty(&dev->power.entry))
                        list_move(&dev->power.entry, &dpm_noirq_list);
                put_device(dev);
+
+               if (pm_wakeup_pending()) {
+                       error = -EBUSY;
+                       break;
+               }
        }
        mutex_unlock(&dpm_list_mtx);
        if (error)
@@ -962,6 +967,11 @@ static int dpm_suspend_late(pm_message_t state)
                if (!list_empty(&dev->power.entry))
                        list_move(&dev->power.entry, &dpm_late_early_list);
                put_device(dev);
+
+               if (pm_wakeup_pending()) {
+                       error = -EBUSY;
+                       break;
+               }
        }
        mutex_unlock(&dpm_list_mtx);
        if (error)