diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2011-02-11 19:42:41 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2011-03-14 19:43:16 -0400 |
commit | e8665002477f0278f84f898145b1f141ba26ee26 (patch) | |
tree | f22348cc3c0cf341216d422e01d2ac033973a0a5 | |
parent | 88a6f33e4d7143f94f8e787fa4065ac873507984 (diff) |
PM: Allow pm_runtime_suspend() to succeed during system suspend
The dpm_prepare() function increments the runtime PM reference
counters of all devices to prevent pm_runtime_suspend() from
executing subsystem-level callbacks. However, this was supposed to
guard against a specific race condition that cannot happen, because
the power management workqueue is freezable, so pm_runtime_suspend()
can only be called synchronously during system suspend and we can
rely on subsystems and device drivers to avoid doing that
unnecessarily.
Make dpm_prepare() drop the runtime PM reference to each device
after making sure that runtime resume is not pending for it.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Kevin Hilman <khilman@ti.com>
-rw-r--r-- | drivers/base/power/main.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 83404973f97a..f7a755923751 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c | |||
@@ -669,7 +669,6 @@ static void dpm_complete(pm_message_t state) | |||
669 | mutex_unlock(&dpm_list_mtx); | 669 | mutex_unlock(&dpm_list_mtx); |
670 | 670 | ||
671 | device_complete(dev, state); | 671 | device_complete(dev, state); |
672 | pm_runtime_put_sync(dev); | ||
673 | 672 | ||
674 | mutex_lock(&dpm_list_mtx); | 673 | mutex_lock(&dpm_list_mtx); |
675 | put_device(dev); | 674 | put_device(dev); |
@@ -1005,12 +1004,9 @@ static int dpm_prepare(pm_message_t state) | |||
1005 | if (pm_runtime_barrier(dev) && device_may_wakeup(dev)) | 1004 | if (pm_runtime_barrier(dev) && device_may_wakeup(dev)) |
1006 | pm_wakeup_event(dev, 0); | 1005 | pm_wakeup_event(dev, 0); |
1007 | 1006 | ||
1008 | if (pm_wakeup_pending()) { | 1007 | pm_runtime_put_sync(dev); |
1009 | pm_runtime_put_sync(dev); | 1008 | error = pm_wakeup_pending() ? |
1010 | error = -EBUSY; | 1009 | -EBUSY : device_prepare(dev, state); |
1011 | } else { | ||
1012 | error = device_prepare(dev, state); | ||
1013 | } | ||
1014 | 1010 | ||
1015 | mutex_lock(&dpm_list_mtx); | 1011 | mutex_lock(&dpm_list_mtx); |
1016 | if (error) { | 1012 | if (error) { |