diff options
author | Colin Cross <ccross@android.com> | 2011-08-10 11:41:59 -0500 |
---|---|---|
committer | Dan Willemsen <dwillemsen@nvidia.com> | 2011-11-30 21:39:08 -0800 |
commit | d69a23cedf782704f6155c2971e836d9b30a2157 (patch) | |
tree | 4cbfa17bff2e47aaeb49fc372580c8b3f755615d /drivers/base/power | |
parent | b761d8388ec21a1da06851ac9ab33bdf755f50ec (diff) |
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>
Diffstat (limited to 'drivers/base/power')
-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 6a7f7b06968f..2a0e392c2fe2 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -753,6 +753,8 @@ int __pm_runtime_idle(struct device *dev, int rpmflags) unsigned long flags; int retval; + might_sleep_if(!(rpmflags & RPM_ASYNC)); + if (rpmflags & RPM_GET_PUT) { if (!atomic_dec_and_test(&dev->power.usage_count)) return 0; @@ -782,6 +784,8 @@ int __pm_runtime_suspend(struct device *dev, int rpmflags) unsigned long flags; int retval; + 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; @@ -810,6 +814,8 @@ int __pm_runtime_resume(struct device *dev, int rpmflags) unsigned long flags; int retval; + might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe); + if (rpmflags & RPM_GET_PUT) atomic_inc(&dev->power.usage_count); @@ -999,6 +1005,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) { @@ -1184,6 +1191,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; |