Lines Matching +full:autosuspend +full:- +full:delay
1 // SPDX-License-Identifier: GPL-2.0
3 #include <linux/blk-mq.h>
4 #include <linux/blk-pm.h>
7 #include "blk-mq.h"
8 #include "blk-mq-tag.h"
11 * blk_pm_runtime_init - Block layer runtime PM initialization routine
16 * Initialize runtime-PM-related fields for @q and start auto suspend for
17 * @dev. Drivers that want to take advantage of request-based runtime PM
24 * the autosuspend delay is set to -1 to make runtime suspend impossible
26 * not need to touch other autosuspend settings.
33 q->dev = dev; in blk_pm_runtime_init()
34 q->rpm_status = RPM_ACTIVE; in blk_pm_runtime_init()
35 pm_runtime_set_autosuspend_delay(q->dev, -1); in blk_pm_runtime_init()
36 pm_runtime_use_autosuspend(q->dev); in blk_pm_runtime_init()
41 * blk_pre_runtime_suspend - Pre runtime suspend check
52 * runtime PM core will try to autosuspend it some time later.
58 * 0 - OK to runtime suspend the device
59 * -EBUSY - Device should not be runtime suspended
65 if (!q->dev) in blk_pre_runtime_suspend()
68 WARN_ON_ONCE(q->rpm_status != RPM_ACTIVE); in blk_pre_runtime_suspend()
72 * non-PM blk_queue_enter() calls are in progress to avoid that any in blk_pre_runtime_suspend()
73 * new non-PM blk_queue_enter() calls succeed before the pm_only in blk_pre_runtime_suspend()
77 ret = -EBUSY; in blk_pre_runtime_suspend()
78 /* Switch q_usage_counter from per-cpu to atomic mode. */ in blk_pre_runtime_suspend()
83 * blk_queue_enter() calls see the pm-only state. See also in blk_pre_runtime_suspend()
86 percpu_ref_switch_to_atomic_sync(&q->q_usage_counter); in blk_pre_runtime_suspend()
87 if (percpu_ref_is_zero(&q->q_usage_counter)) in blk_pre_runtime_suspend()
89 /* Switch q_usage_counter back to per-cpu mode. */ in blk_pre_runtime_suspend()
92 spin_lock_irq(&q->queue_lock); in blk_pre_runtime_suspend()
94 pm_runtime_mark_last_busy(q->dev); in blk_pre_runtime_suspend()
96 q->rpm_status = RPM_SUSPENDING; in blk_pre_runtime_suspend()
97 spin_unlock_irq(&q->queue_lock); in blk_pre_runtime_suspend()
107 * blk_post_runtime_suspend - Post runtime suspend processing
121 if (!q->dev) in blk_post_runtime_suspend()
124 spin_lock_irq(&q->queue_lock); in blk_post_runtime_suspend()
126 q->rpm_status = RPM_SUSPENDED; in blk_post_runtime_suspend()
128 q->rpm_status = RPM_ACTIVE; in blk_post_runtime_suspend()
129 pm_runtime_mark_last_busy(q->dev); in blk_post_runtime_suspend()
131 spin_unlock_irq(&q->queue_lock); in blk_post_runtime_suspend()
139 * blk_pre_runtime_resume - Pre runtime resume processing
151 if (!q->dev) in blk_pre_runtime_resume()
154 spin_lock_irq(&q->queue_lock); in blk_pre_runtime_resume()
155 q->rpm_status = RPM_RESUMING; in blk_pre_runtime_resume()
156 spin_unlock_irq(&q->queue_lock); in blk_pre_runtime_resume()
161 * blk_post_runtime_resume - Post runtime resume processing
175 if (!q->dev) in blk_post_runtime_resume()
180 spin_lock_irq(&q->queue_lock); in blk_post_runtime_resume()
181 q->rpm_status = RPM_SUSPENDED; in blk_post_runtime_resume()
182 spin_unlock_irq(&q->queue_lock); in blk_post_runtime_resume()
188 * blk_set_runtime_active - Force runtime status of the queue to be active
198 * runtime PM status and re-enable peeking requests from the queue. It
208 if (!q->dev) in blk_set_runtime_active()
211 spin_lock_irq(&q->queue_lock); in blk_set_runtime_active()
212 old_status = q->rpm_status; in blk_set_runtime_active()
213 q->rpm_status = RPM_ACTIVE; in blk_set_runtime_active()
214 pm_runtime_mark_last_busy(q->dev); in blk_set_runtime_active()
215 pm_request_autosuspend(q->dev); in blk_set_runtime_active()
216 spin_unlock_irq(&q->queue_lock); in blk_set_runtime_active()