aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/power
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2011-06-18 16:42:09 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2011-06-21 17:20:20 -0400
commit6d0e0e84f66d32c33511984dd3badd32364b863c (patch)
tree215916af1632fbaff9d46676d14dafd52143d578 /drivers/base/power
parent8440f4b19494467883f8541b7aa28c7bbf6ac92b (diff)
PM: Fix async resume following suspend failure
The PM core doesn't handle suspend failures correctly when it comes to asynchronously suspended devices. These devices are moved onto the dpm_suspended_list as soon as the corresponding async thread is started up, and they remain on the list even if they fail to suspend or the sleep transition is cancelled before they get suspended. As a result, when the PM core unwinds the transition, it tries to resume the devices even though they were never suspended. This patch (as1474) fixes the problem by adding a new "is_suspended" flag to dev_pm_info. Devices are resumed only if the flag is set. [rjw: * Moved the dev->power.is_suspended check into device_resume(), because we need to complete dev->power.completion and clear dev->power.is_prepared too for devices whose dev->power.is_suspended flags are unset. * Fixed __device_suspend() to avoid setting dev->power.is_suspended if async_error is different from zero.] Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Cc: stable@kernel.org
Diffstat (limited to 'drivers/base/power')
-rw-r--r--drivers/base/power/main.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index bf5a59ac195..06f09bf89cb 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -58,6 +58,7 @@ static int async_error;
58void device_pm_init(struct device *dev) 58void device_pm_init(struct device *dev)
59{ 59{
60 dev->power.is_prepared = false; 60 dev->power.is_prepared = false;
61 dev->power.is_suspended = false;
61 init_completion(&dev->power.completion); 62 init_completion(&dev->power.completion);
62 complete_all(&dev->power.completion); 63 complete_all(&dev->power.completion);
63 dev->power.wakeup = NULL; 64 dev->power.wakeup = NULL;
@@ -517,6 +518,9 @@ static int device_resume(struct device *dev, pm_message_t state, bool async)
517 */ 518 */
518 dev->power.is_prepared = false; 519 dev->power.is_prepared = false;
519 520
521 if (!dev->power.is_suspended)
522 goto Unlock;
523
520 if (dev->pwr_domain) { 524 if (dev->pwr_domain) {
521 pm_dev_dbg(dev, state, "power domain "); 525 pm_dev_dbg(dev, state, "power domain ");
522 error = pm_op(dev, &dev->pwr_domain->ops, state); 526 error = pm_op(dev, &dev->pwr_domain->ops, state);
@@ -552,6 +556,9 @@ static int device_resume(struct device *dev, pm_message_t state, bool async)
552 } 556 }
553 557
554 End: 558 End:
559 dev->power.is_suspended = false;
560
561 Unlock:
555 device_unlock(dev); 562 device_unlock(dev);
556 complete_all(&dev->power.completion); 563 complete_all(&dev->power.completion);
557 564
@@ -839,11 +846,11 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
839 device_lock(dev); 846 device_lock(dev);
840 847
841 if (async_error) 848 if (async_error)
842 goto End; 849 goto Unlock;
843 850
844 if (pm_wakeup_pending()) { 851 if (pm_wakeup_pending()) {
845 async_error = -EBUSY; 852 async_error = -EBUSY;
846 goto End; 853 goto Unlock;
847 } 854 }
848 855
849 if (dev->pwr_domain) { 856 if (dev->pwr_domain) {
@@ -881,6 +888,9 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
881 } 888 }
882 889
883 End: 890 End:
891 dev->power.is_suspended = !error;
892
893 Unlock:
884 device_unlock(dev); 894 device_unlock(dev);
885 complete_all(&dev->power.completion); 895 complete_all(&dev->power.completion);
886 896