diff options
author | Colin Cross <ccross@android.com> | 2011-12-13 01:23:55 +0800 |
---|---|---|
committer | Andy Green <andy.green@linaro.org> | 2012-01-09 10:54:08 +0800 |
commit | 5c0e0451bf7ab410fd2b4a8606a9d415e83cc1b8 (patch) | |
tree | 4167b478a53dd3bfdc02d63d4188f6b3a1800bc8 | |
parent | 9c5d24b73400a24eac57029d49798bc3fd68bf3f (diff) | |
download | imx53-5c0e0451bf7ab410fd2b4a8606a9d415e83cc1b8.tar.gz |
PM: runtime: add might_sleep to PM runtime functions
The list of functions that can be called in atomic context is
non-intuitive (pm_runtime_put_sync can not, but
pm_runtime_put_sync_suspend can, if pm_runtime_irq_safe has
been called?). The code is actively misleading - the entry
points all start with spin_lock_irqsave, suggesting they
are safe to call in atomic context, but may later
enable interrupts.
Add might_sleep_if to all the __pm_runtime_* entry points
to enforce correct usage.
Also add pm_runtime_put_sync_autosuspend to the list of
functions that can be called in atomic context.
Change-Id: Icac17a10d77c64d44bd2761a91a588dfd1d0c6f0
Signed-off-by: Colin Cross <ccross@android.com>
-rw-r--r-- | drivers/base/power/runtime.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 8c78443bca8..79b78f7887d 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -784,6 +784,8 @@ int __pm_runtime_idle(struct device *dev, int rpmflags) might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe); + might_sleep_if(!(rpmflags & RPM_ASYNC)); + if (rpmflags & RPM_GET_PUT) { if (!atomic_dec_and_test(&dev->power.usage_count)) return 0; @@ -816,6 +818,8 @@ int __pm_runtime_suspend(struct device *dev, int rpmflags) might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe); + might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe); + if (rpmflags & RPM_GET_PUT) { if (!atomic_dec_and_test(&dev->power.usage_count)) return 0; @@ -847,6 +851,8 @@ int __pm_runtime_resume(struct device *dev, int rpmflags) might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe); + might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe); + if (rpmflags & RPM_GET_PUT) atomic_inc(&dev->power.usage_count); @@ -1036,6 +1042,7 @@ EXPORT_SYMBOL_GPL(pm_runtime_barrier); */ void __pm_runtime_disable(struct device *dev, bool check_resume) { + might_sleep(); spin_lock_irq(&dev->power.lock); if (dev->power.disable_depth > 0) { @@ -1221,6 +1228,8 @@ void pm_runtime_set_autosuspend_delay(struct device *dev, int delay) { int old_delay, old_use; + might_sleep(); + spin_lock_irq(&dev->power.lock); old_delay = dev->power.autosuspend_delay; old_use = dev->power.use_autosuspend; |