Lines Matching full:power
3 * drivers/base/power/runtime.c - Helper functions for device runtime PM
17 #include "power.h"
55 * update_pm_runtime_accounting - Update the time accounting of power states
58 * In order to be able to have time accounting of the various power states
69 if (dev->power.disable_depth > 0) in update_pm_runtime_accounting()
72 last = dev->power.accounting_timestamp; in update_pm_runtime_accounting()
75 dev->power.accounting_timestamp = now; in update_pm_runtime_accounting()
87 if (dev->power.runtime_status == RPM_SUSPENDED) in update_pm_runtime_accounting()
88 dev->power.suspended_time += delta; in update_pm_runtime_accounting()
90 dev->power.active_time += delta; in update_pm_runtime_accounting()
96 dev->power.runtime_status = status; in __update_runtime_status()
104 spin_lock_irqsave(&dev->power.lock, flags); in rpm_get_accounted_time()
107 time = suspended ? dev->power.suspended_time : dev->power.active_time; in rpm_get_accounted_time()
109 spin_unlock_irqrestore(&dev->power.lock, flags); in rpm_get_accounted_time()
131 if (dev->power.timer_expires > 0) { in pm_runtime_deactivate_timer()
132 hrtimer_try_to_cancel(&dev->power.suspend_timer); in pm_runtime_deactivate_timer()
133 dev->power.timer_expires = 0; in pm_runtime_deactivate_timer()
148 dev->power.request = RPM_REQ_NONE; in pm_runtime_cancel_pending()
156 * power.last_busy time. If the delay has already expired or is disabled
157 * (negative) or the power.use_autosuspend flag isn't set, return 0.
160 * This function may be called either with or without dev->power.lock held.
161 * Either way it can be racy, since power.last_busy may be updated at any time.
168 if (!dev->power.use_autosuspend) in pm_runtime_autosuspend_expiration()
171 autosuspend_delay = READ_ONCE(dev->power.autosuspend_delay); in pm_runtime_autosuspend_expiration()
175 expires = READ_ONCE(dev->power.last_busy); in pm_runtime_autosuspend_expiration()
186 return dev->power.memalloc_noio; in dev_memalloc_noio()
225 /* hold power lock since bitfield is not SMP-safe. */ in pm_runtime_set_memalloc_noio()
226 spin_lock_irq(&dev->power.lock); in pm_runtime_set_memalloc_noio()
227 enabled = dev->power.memalloc_noio; in pm_runtime_set_memalloc_noio()
228 dev->power.memalloc_noio = enable; in pm_runtime_set_memalloc_noio()
229 spin_unlock_irq(&dev->power.lock); in pm_runtime_set_memalloc_noio()
262 if (dev->power.runtime_error) in rpm_check_suspend_allowed()
264 else if (dev->power.disable_depth > 0) in rpm_check_suspend_allowed()
266 else if (atomic_read(&dev->power.usage_count) > 0) in rpm_check_suspend_allowed()
268 else if (!dev->power.ignore_children && in rpm_check_suspend_allowed()
269 atomic_read(&dev->power.child_count)) in rpm_check_suspend_allowed()
273 else if ((dev->power.deferred_resume in rpm_check_suspend_allowed()
274 && dev->power.runtime_status == RPM_SUSPENDING) in rpm_check_suspend_allowed()
275 || (dev->power.request_pending in rpm_check_suspend_allowed()
276 && dev->power.request == RPM_REQ_RESUME)) in rpm_check_suspend_allowed()
280 else if (dev->power.runtime_status == RPM_SUSPENDED) in rpm_check_suspend_allowed()
319 * The additional power.usage_count check is a safety net in case in pm_runtime_release_supplier()
325 atomic_read(&supplier->power.usage_count) > 0) in pm_runtime_release_supplier()
364 __releases(&dev->power.lock) __acquires(&dev->power.lock) in __rpm_callback()
367 bool use_links = dev->power.links_count > 0; in __rpm_callback()
369 if (dev->power.irq_safe) { in __rpm_callback()
370 spin_unlock(&dev->power.lock); in __rpm_callback()
372 spin_unlock_irq(&dev->power.lock); in __rpm_callback()
381 if (use_links && dev->power.runtime_status == RPM_RESUMING) { in __rpm_callback()
396 if (dev->power.irq_safe) { in __rpm_callback()
397 spin_lock(&dev->power.lock); in __rpm_callback()
407 && ((dev->power.runtime_status == RPM_SUSPENDING && !retval) in __rpm_callback()
408 || (dev->power.runtime_status == RPM_RESUMING && retval))) { in __rpm_callback()
417 spin_lock_irq(&dev->power.lock); in __rpm_callback()
434 * This function must be called under dev->power.lock with interrupts disabled.
447 else if (dev->power.runtime_status != RPM_ACTIVE) in rpm_idle()
454 else if (dev->power.request_pending && in rpm_idle()
455 dev->power.request > RPM_REQ_IDLE) in rpm_idle()
459 else if (dev->power.idle_notification) in rpm_idle()
465 dev->power.request = RPM_REQ_NONE; in rpm_idle()
470 if (!callback || dev->power.no_callbacks) in rpm_idle()
475 dev->power.request = RPM_REQ_IDLE; in rpm_idle()
476 if (!dev->power.request_pending) { in rpm_idle()
477 dev->power.request_pending = true; in rpm_idle()
478 queue_work(pm_wq, &dev->power.work); in rpm_idle()
484 dev->power.idle_notification = true; in rpm_idle()
486 if (dev->power.irq_safe) in rpm_idle()
487 spin_unlock(&dev->power.lock); in rpm_idle()
489 spin_unlock_irq(&dev->power.lock); in rpm_idle()
493 if (dev->power.irq_safe) in rpm_idle()
494 spin_lock(&dev->power.lock); in rpm_idle()
496 spin_lock_irq(&dev->power.lock); in rpm_idle()
498 dev->power.idle_notification = false; in rpm_idle()
499 wake_up_all(&dev->power.wait_queue); in rpm_idle()
518 if (dev->power.memalloc_noio) { in rpm_callback()
537 dev->power.runtime_error = retval; in rpm_callback()
555 * ignore_children of parent->power and irq_safe of dev->power are not set).
560 * This function must be called under dev->power.lock with interrupts disabled.
563 __releases(&dev->power.lock) __acquires(&dev->power.lock) in rpm_suspend()
577 if (dev->power.runtime_status == RPM_RESUMING && !(rpmflags & RPM_ASYNC)) in rpm_suspend()
584 && dev->power.runtime_status != RPM_SUSPENDING) { in rpm_suspend()
589 dev->power.request = RPM_REQ_NONE; in rpm_suspend()
598 if (!(dev->power.timer_expires && in rpm_suspend()
599 dev->power.timer_expires <= expires)) { in rpm_suspend()
604 u64 slack = (u64)READ_ONCE(dev->power.autosuspend_delay) * in rpm_suspend()
607 dev->power.timer_expires = expires; in rpm_suspend()
608 hrtimer_start_range_ns(&dev->power.suspend_timer, in rpm_suspend()
613 dev->power.timer_autosuspends = 1; in rpm_suspend()
621 if (dev->power.runtime_status == RPM_SUSPENDING) { in rpm_suspend()
629 if (dev->power.irq_safe) { in rpm_suspend()
630 spin_unlock(&dev->power.lock); in rpm_suspend()
634 spin_lock(&dev->power.lock); in rpm_suspend()
640 prepare_to_wait(&dev->power.wait_queue, &wait, in rpm_suspend()
642 if (dev->power.runtime_status != RPM_SUSPENDING) in rpm_suspend()
645 spin_unlock_irq(&dev->power.lock); in rpm_suspend()
649 spin_lock_irq(&dev->power.lock); in rpm_suspend()
651 finish_wait(&dev->power.wait_queue, &wait); in rpm_suspend()
655 if (dev->power.no_callbacks) in rpm_suspend()
660 dev->power.request = (rpmflags & RPM_AUTO) ? in rpm_suspend()
662 if (!dev->power.request_pending) { in rpm_suspend()
663 dev->power.request_pending = true; in rpm_suspend()
664 queue_work(pm_wq, &dev->power.work); in rpm_suspend()
684 atomic_add_unless(&parent->power.child_count, -1, 0); in rpm_suspend()
686 wake_up_all(&dev->power.wait_queue); in rpm_suspend()
688 if (dev->power.deferred_resume) { in rpm_suspend()
689 dev->power.deferred_resume = false; in rpm_suspend()
695 if (dev->power.irq_safe) in rpm_suspend()
699 if (parent && !parent->power.ignore_children) { in rpm_suspend()
700 spin_unlock(&dev->power.lock); in rpm_suspend()
702 spin_lock(&parent->power.lock); in rpm_suspend()
704 spin_unlock(&parent->power.lock); in rpm_suspend()
706 spin_lock(&dev->power.lock); in rpm_suspend()
709 if (dev->power.links_count > 0) { in rpm_suspend()
710 spin_unlock_irq(&dev->power.lock); in rpm_suspend()
714 spin_lock_irq(&dev->power.lock); in rpm_suspend()
725 dev->power.deferred_resume = false; in rpm_suspend()
726 wake_up_all(&dev->power.wait_queue); in rpm_suspend()
729 dev->power.runtime_error = 0; in rpm_suspend()
761 * This function must be called under dev->power.lock with interrupts disabled.
764 __releases(&dev->power.lock) __acquires(&dev->power.lock) in rpm_resume()
773 if (dev->power.runtime_error) in rpm_resume()
775 else if (dev->power.disable_depth == 1 && dev->power.is_suspended in rpm_resume()
776 && dev->power.runtime_status == RPM_ACTIVE) in rpm_resume()
778 else if (dev->power.disable_depth > 0) in rpm_resume()
789 dev->power.request = RPM_REQ_NONE; in rpm_resume()
790 if (!dev->power.timer_autosuspends) in rpm_resume()
793 if (dev->power.runtime_status == RPM_ACTIVE) { in rpm_resume()
798 if (dev->power.runtime_status == RPM_RESUMING in rpm_resume()
799 || dev->power.runtime_status == RPM_SUSPENDING) { in rpm_resume()
803 if (dev->power.runtime_status == RPM_SUSPENDING) in rpm_resume()
804 dev->power.deferred_resume = true; in rpm_resume()
810 if (dev->power.irq_safe) { in rpm_resume()
811 spin_unlock(&dev->power.lock); in rpm_resume()
815 spin_lock(&dev->power.lock); in rpm_resume()
821 prepare_to_wait(&dev->power.wait_queue, &wait, in rpm_resume()
823 if (dev->power.runtime_status != RPM_RESUMING in rpm_resume()
824 && dev->power.runtime_status != RPM_SUSPENDING) in rpm_resume()
827 spin_unlock_irq(&dev->power.lock); in rpm_resume()
831 spin_lock_irq(&dev->power.lock); in rpm_resume()
833 finish_wait(&dev->power.wait_queue, &wait); in rpm_resume()
839 * power.no_callbacks is set, because otherwise we don't know whether in rpm_resume()
842 if (dev->power.no_callbacks && !parent && dev->parent) { in rpm_resume()
843 spin_lock_nested(&dev->parent->power.lock, SINGLE_DEPTH_NESTING); in rpm_resume()
844 if (dev->parent->power.disable_depth > 0 in rpm_resume()
845 || dev->parent->power.ignore_children in rpm_resume()
846 || dev->parent->power.runtime_status == RPM_ACTIVE) { in rpm_resume()
847 atomic_inc(&dev->parent->power.child_count); in rpm_resume()
848 spin_unlock(&dev->parent->power.lock); in rpm_resume()
852 spin_unlock(&dev->parent->power.lock); in rpm_resume()
857 dev->power.request = RPM_REQ_RESUME; in rpm_resume()
858 if (!dev->power.request_pending) { in rpm_resume()
859 dev->power.request_pending = true; in rpm_resume()
860 queue_work(pm_wq, &dev->power.work); in rpm_resume()
873 if (dev->power.irq_safe) in rpm_resume()
875 spin_unlock(&dev->power.lock); in rpm_resume()
879 spin_lock(&parent->power.lock); in rpm_resume()
884 if (!parent->power.disable_depth in rpm_resume()
885 && !parent->power.ignore_children) { in rpm_resume()
887 if (parent->power.runtime_status != RPM_ACTIVE) in rpm_resume()
890 spin_unlock(&parent->power.lock); in rpm_resume()
892 spin_lock(&dev->power.lock); in rpm_resume()
899 if (dev->power.no_callbacks) in rpm_resume()
917 atomic_inc(&parent->power.child_count); in rpm_resume()
919 wake_up_all(&dev->power.wait_queue); in rpm_resume()
925 if (parent && !dev->power.irq_safe) { in rpm_resume()
926 spin_unlock_irq(&dev->power.lock); in rpm_resume()
930 spin_lock_irq(&dev->power.lock); in rpm_resume()
947 struct device *dev = container_of(work, struct device, power.work); in pm_runtime_work()
950 spin_lock_irq(&dev->power.lock); in pm_runtime_work()
952 if (!dev->power.request_pending) in pm_runtime_work()
955 req = dev->power.request; in pm_runtime_work()
956 dev->power.request = RPM_REQ_NONE; in pm_runtime_work()
957 dev->power.request_pending = false; in pm_runtime_work()
977 spin_unlock_irq(&dev->power.lock); in pm_runtime_work()
988 struct device *dev = container_of(timer, struct device, power.suspend_timer); in pm_suspend_timer_fn()
992 spin_lock_irqsave(&dev->power.lock, flags); in pm_suspend_timer_fn()
994 expires = dev->power.timer_expires; in pm_suspend_timer_fn()
1000 dev->power.timer_expires = 0; in pm_suspend_timer_fn()
1001 rpm_suspend(dev, dev->power.timer_autosuspends ? in pm_suspend_timer_fn()
1005 spin_unlock_irqrestore(&dev->power.lock, flags); in pm_suspend_timer_fn()
1021 spin_lock_irqsave(&dev->power.lock, flags); in pm_schedule_suspend()
1036 dev->power.timer_expires = expires; in pm_schedule_suspend()
1037 dev->power.timer_autosuspends = 0; in pm_schedule_suspend()
1038 hrtimer_start(&dev->power.suspend_timer, expires, HRTIMER_MODE_ABS); in pm_schedule_suspend()
1041 spin_unlock_irqrestore(&dev->power.lock, flags); in pm_schedule_suspend()
1065 if (!atomic_dec_and_test(&dev->power.usage_count)) { in __pm_runtime_idle()
1071 might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe); in __pm_runtime_idle()
1073 spin_lock_irqsave(&dev->power.lock, flags); in __pm_runtime_idle()
1075 spin_unlock_irqrestore(&dev->power.lock, flags); in __pm_runtime_idle()
1099 if (!atomic_dec_and_test(&dev->power.usage_count)) { in __pm_runtime_suspend()
1105 might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe); in __pm_runtime_suspend()
1107 spin_lock_irqsave(&dev->power.lock, flags); in __pm_runtime_suspend()
1109 spin_unlock_irqrestore(&dev->power.lock, flags); in __pm_runtime_suspend()
1131 might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe && in __pm_runtime_resume()
1132 dev->power.runtime_status != RPM_ACTIVE); in __pm_runtime_resume()
1135 atomic_inc(&dev->power.usage_count); in __pm_runtime_resume()
1137 spin_lock_irqsave(&dev->power.lock, flags); in __pm_runtime_resume()
1139 spin_unlock_irqrestore(&dev->power.lock, flags); in __pm_runtime_resume()
1172 spin_lock_irqsave(&dev->power.lock, flags); in pm_runtime_get_if_active()
1173 if (dev->power.disable_depth > 0) { in pm_runtime_get_if_active()
1175 } else if (dev->power.runtime_status != RPM_ACTIVE) { in pm_runtime_get_if_active()
1179 atomic_inc(&dev->power.usage_count); in pm_runtime_get_if_active()
1181 retval = atomic_inc_not_zero(&dev->power.usage_count); in pm_runtime_get_if_active()
1184 spin_unlock_irqrestore(&dev->power.lock, flags); in pm_runtime_get_if_active()
1195 * If runtime PM of the device is disabled or its power.runtime_error field is
1199 * parent's power.ignore_children flag is unset, the device's status cannot be
1202 * If successful, __pm_runtime_set_status() clears the power.runtime_error field
1223 spin_lock_irq(&dev->power.lock); in __pm_runtime_set_status()
1229 if (dev->power.runtime_error || dev->power.disable_depth) in __pm_runtime_set_status()
1230 dev->power.disable_depth++; in __pm_runtime_set_status()
1234 spin_unlock_irq(&dev->power.lock); in __pm_runtime_set_status()
1255 spin_lock_irq(&dev->power.lock); in __pm_runtime_set_status()
1257 if (dev->power.runtime_status == status || !parent) in __pm_runtime_set_status()
1261 atomic_add_unless(&parent->power.child_count, -1, 0); in __pm_runtime_set_status()
1262 notify_parent = !parent->power.ignore_children; in __pm_runtime_set_status()
1264 spin_lock_nested(&parent->power.lock, SINGLE_DEPTH_NESTING); in __pm_runtime_set_status()
1269 * 'power.ignore_children' flag unset. in __pm_runtime_set_status()
1271 if (!parent->power.disable_depth in __pm_runtime_set_status()
1272 && !parent->power.ignore_children in __pm_runtime_set_status()
1273 && parent->power.runtime_status != RPM_ACTIVE) { in __pm_runtime_set_status()
1278 } else if (dev->power.runtime_status == RPM_SUSPENDED) { in __pm_runtime_set_status()
1279 atomic_inc(&parent->power.child_count); in __pm_runtime_set_status()
1282 spin_unlock(&parent->power.lock); in __pm_runtime_set_status()
1293 dev->power.runtime_error = 0; in __pm_runtime_set_status()
1296 spin_unlock_irq(&dev->power.lock); in __pm_runtime_set_status()
1322 * Should be called under dev->power.lock with interrupts disabled.
1328 if (dev->power.request_pending) { in __pm_runtime_barrier()
1329 dev->power.request = RPM_REQ_NONE; in __pm_runtime_barrier()
1330 spin_unlock_irq(&dev->power.lock); in __pm_runtime_barrier()
1332 cancel_work_sync(&dev->power.work); in __pm_runtime_barrier()
1334 spin_lock_irq(&dev->power.lock); in __pm_runtime_barrier()
1335 dev->power.request_pending = false; in __pm_runtime_barrier()
1338 if (dev->power.runtime_status == RPM_SUSPENDING in __pm_runtime_barrier()
1339 || dev->power.runtime_status == RPM_RESUMING in __pm_runtime_barrier()
1340 || dev->power.idle_notification) { in __pm_runtime_barrier()
1345 prepare_to_wait(&dev->power.wait_queue, &wait, in __pm_runtime_barrier()
1347 if (dev->power.runtime_status != RPM_SUSPENDING in __pm_runtime_barrier()
1348 && dev->power.runtime_status != RPM_RESUMING in __pm_runtime_barrier()
1349 && !dev->power.idle_notification) in __pm_runtime_barrier()
1351 spin_unlock_irq(&dev->power.lock); in __pm_runtime_barrier()
1355 spin_lock_irq(&dev->power.lock); in __pm_runtime_barrier()
1357 finish_wait(&dev->power.wait_queue, &wait); in __pm_runtime_barrier()
1380 spin_lock_irq(&dev->power.lock); in pm_runtime_barrier()
1382 if (dev->power.request_pending in pm_runtime_barrier()
1383 && dev->power.request == RPM_REQ_RESUME) { in pm_runtime_barrier()
1390 spin_unlock_irq(&dev->power.lock); in pm_runtime_barrier()
1402 * Increment power.disable_depth for the device and if it was zero previously,
1408 * __pm_runtime_disable() is called and power.disable_depth is zero, the
1413 spin_lock_irq(&dev->power.lock); in __pm_runtime_disable()
1415 if (dev->power.disable_depth > 0) { in __pm_runtime_disable()
1416 dev->power.disable_depth++; in __pm_runtime_disable()
1425 if (check_resume && dev->power.request_pending in __pm_runtime_disable()
1426 && dev->power.request == RPM_REQ_RESUME) { in __pm_runtime_disable()
1441 if (!dev->power.disable_depth++) in __pm_runtime_disable()
1445 spin_unlock_irq(&dev->power.lock); in __pm_runtime_disable()
1457 spin_lock_irqsave(&dev->power.lock, flags); in pm_runtime_enable()
1459 if (dev->power.disable_depth > 0) { in pm_runtime_enable()
1460 dev->power.disable_depth--; in pm_runtime_enable()
1463 if (!dev->power.disable_depth) in pm_runtime_enable()
1464 dev->power.accounting_timestamp = ktime_get_mono_fast_ns(); in pm_runtime_enable()
1469 WARN(!dev->power.disable_depth && in pm_runtime_enable()
1470 dev->power.runtime_status == RPM_SUSPENDED && in pm_runtime_enable()
1471 !dev->power.ignore_children && in pm_runtime_enable()
1472 atomic_read(&dev->power.child_count) > 0, in pm_runtime_enable()
1476 spin_unlock_irqrestore(&dev->power.lock, flags); in pm_runtime_enable()
1484 * Increase the device's usage count and clear its power.runtime_auto flag,
1490 spin_lock_irq(&dev->power.lock); in pm_runtime_forbid()
1491 if (!dev->power.runtime_auto) in pm_runtime_forbid()
1494 dev->power.runtime_auto = false; in pm_runtime_forbid()
1495 atomic_inc(&dev->power.usage_count); in pm_runtime_forbid()
1499 spin_unlock_irq(&dev->power.lock); in pm_runtime_forbid()
1507 * Decrease the device's usage count and set its power.runtime_auto flag.
1511 spin_lock_irq(&dev->power.lock); in pm_runtime_allow()
1512 if (dev->power.runtime_auto) in pm_runtime_allow()
1515 dev->power.runtime_auto = true; in pm_runtime_allow()
1516 if (atomic_dec_and_test(&dev->power.usage_count)) in pm_runtime_allow()
1522 spin_unlock_irq(&dev->power.lock); in pm_runtime_allow()
1530 * Set the power.no_callbacks flag, which tells the PM core that this
1531 * device is power-managed through its parent and has no runtime PM
1536 spin_lock_irq(&dev->power.lock); in pm_runtime_no_callbacks()
1537 dev->power.no_callbacks = 1; in pm_runtime_no_callbacks()
1538 spin_unlock_irq(&dev->power.lock); in pm_runtime_no_callbacks()
1548 * Set the power.irq_safe flag, which tells the PM core that the
1559 spin_lock_irq(&dev->power.lock); in pm_runtime_irq_safe()
1560 dev->power.irq_safe = 1; in pm_runtime_irq_safe()
1561 spin_unlock_irq(&dev->power.lock); in pm_runtime_irq_safe()
1574 * This function must be called under dev->power.lock with interrupts disabled.
1578 int delay = dev->power.autosuspend_delay; in update_autosuspend()
1581 if (dev->power.use_autosuspend && delay < 0) { in update_autosuspend()
1585 atomic_inc(&dev->power.usage_count); in update_autosuspend()
1597 atomic_dec(&dev->power.usage_count); in update_autosuspend()
1609 * Set the device's power.autosuspend_delay value. If it changes to negative
1610 * and the power.use_autosuspend flag is set, prevent runtime suspends. If it
1617 spin_lock_irq(&dev->power.lock); in pm_runtime_set_autosuspend_delay()
1618 old_delay = dev->power.autosuspend_delay; in pm_runtime_set_autosuspend_delay()
1619 old_use = dev->power.use_autosuspend; in pm_runtime_set_autosuspend_delay()
1620 dev->power.autosuspend_delay = delay; in pm_runtime_set_autosuspend_delay()
1622 spin_unlock_irq(&dev->power.lock); in pm_runtime_set_autosuspend_delay()
1631 * Set the device's power.use_autosuspend flag, and allow or prevent runtime
1638 spin_lock_irq(&dev->power.lock); in __pm_runtime_use_autosuspend()
1639 old_delay = dev->power.autosuspend_delay; in __pm_runtime_use_autosuspend()
1640 old_use = dev->power.use_autosuspend; in __pm_runtime_use_autosuspend()
1641 dev->power.use_autosuspend = use; in __pm_runtime_use_autosuspend()
1643 spin_unlock_irq(&dev->power.lock); in __pm_runtime_use_autosuspend()
1653 dev->power.runtime_status = RPM_SUSPENDED; in pm_runtime_init()
1654 dev->power.idle_notification = false; in pm_runtime_init()
1656 dev->power.disable_depth = 1; in pm_runtime_init()
1657 atomic_set(&dev->power.usage_count, 0); in pm_runtime_init()
1659 dev->power.runtime_error = 0; in pm_runtime_init()
1661 atomic_set(&dev->power.child_count, 0); in pm_runtime_init()
1663 dev->power.runtime_auto = true; in pm_runtime_init()
1665 dev->power.request_pending = false; in pm_runtime_init()
1666 dev->power.request = RPM_REQ_NONE; in pm_runtime_init()
1667 dev->power.deferred_resume = false; in pm_runtime_init()
1668 dev->power.needs_force_resume = 0; in pm_runtime_init()
1669 INIT_WORK(&dev->power.work, pm_runtime_work); in pm_runtime_init()
1671 dev->power.timer_expires = 0; in pm_runtime_init()
1672 hrtimer_init(&dev->power.suspend_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); in pm_runtime_init()
1673 dev->power.suspend_timer.function = pm_suspend_timer_fn; in pm_runtime_init()
1675 init_waitqueue_head(&dev->power.wait_queue); in pm_runtime_init()
1685 if (dev->power.runtime_status == RPM_ACTIVE) in pm_runtime_reinit()
1687 if (dev->power.irq_safe) { in pm_runtime_reinit()
1688 spin_lock_irq(&dev->power.lock); in pm_runtime_reinit()
1689 dev->power.irq_safe = 0; in pm_runtime_reinit()
1690 spin_unlock_irq(&dev->power.lock); in pm_runtime_reinit()
1746 spin_lock_irqsave(&dev->power.lock, flags); in pm_runtime_put_suppliers()
1749 spin_unlock_irqrestore(&dev->power.lock, flags); in pm_runtime_put_suppliers()
1759 spin_lock_irq(&dev->power.lock); in pm_runtime_new_link()
1760 dev->power.links_count++; in pm_runtime_new_link()
1761 spin_unlock_irq(&dev->power.lock); in pm_runtime_new_link()
1766 spin_lock_irq(&dev->power.lock); in pm_runtime_drop_link_count()
1767 WARN_ON(dev->power.links_count == 0); in pm_runtime_drop_link_count()
1768 dev->power.links_count--; in pm_runtime_drop_link_count()
1769 spin_unlock_irq(&dev->power.lock); in pm_runtime_drop_link_count()
1792 return atomic_read(&dev->power.usage_count) <= 1 && in pm_runtime_need_not_resume()
1793 (atomic_read(&dev->power.child_count) == 0 || in pm_runtime_need_not_resume()
1794 dev->power.ignore_children); in pm_runtime_need_not_resume()
1810 * sure the device is put into low power state and it should only be used during
1839 dev->power.needs_force_resume = 1; in pm_runtime_force_suspend()
1855 * into low power state by a call to pm_runtime_force_suspend(). Here we reverse
1856 * those actions and bring the device into full power, if it is expected to be
1867 if (!pm_runtime_status_suspended(dev) || !dev->power.needs_force_resume) in pm_runtime_force_resume()
1886 dev->power.needs_force_resume = 0; in pm_runtime_force_resume()