Lines Matching +full:post +full:- +full:processing
1 // SPDX-License-Identifier: GPL-2.0
3 #include <linux/blk-pm.h>
6 #include "blk-mq.h"
9 * blk_pm_runtime_init - Block layer runtime PM initialization routine
14 * Initialize runtime-PM-related fields for @q and start auto suspend for
15 * @dev. Drivers that want to take advantage of request-based runtime PM
22 * the autosuspend delay is set to -1 to make runtime suspend impossible
31 q->dev = dev; in blk_pm_runtime_init()
32 q->rpm_status = RPM_ACTIVE; in blk_pm_runtime_init()
33 pm_runtime_set_autosuspend_delay(q->dev, -1); in blk_pm_runtime_init()
34 pm_runtime_use_autosuspend(q->dev); in blk_pm_runtime_init()
39 * blk_pre_runtime_suspend - Pre runtime suspend check
56 * 0 - OK to runtime suspend the device
57 * -EBUSY - Device should not be runtime suspended
63 if (!q->dev) in blk_pre_runtime_suspend()
66 WARN_ON_ONCE(q->rpm_status != RPM_ACTIVE); in blk_pre_runtime_suspend()
68 spin_lock_irq(&q->queue_lock); in blk_pre_runtime_suspend()
69 q->rpm_status = RPM_SUSPENDING; in blk_pre_runtime_suspend()
70 spin_unlock_irq(&q->queue_lock); in blk_pre_runtime_suspend()
74 * non-PM blk_queue_enter() calls are in progress to avoid that any in blk_pre_runtime_suspend()
75 * new non-PM blk_queue_enter() calls succeed before the pm_only in blk_pre_runtime_suspend()
79 ret = -EBUSY; in blk_pre_runtime_suspend()
80 /* Switch q_usage_counter from per-cpu to atomic mode. */ in blk_pre_runtime_suspend()
85 * blk_queue_enter() calls see the pm-only state. See also in blk_pre_runtime_suspend()
88 percpu_ref_switch_to_atomic_sync(&q->q_usage_counter); in blk_pre_runtime_suspend()
89 if (percpu_ref_is_zero(&q->q_usage_counter)) in blk_pre_runtime_suspend()
91 /* Switch q_usage_counter back to per-cpu mode. */ in blk_pre_runtime_suspend()
95 spin_lock_irq(&q->queue_lock); in blk_pre_runtime_suspend()
96 q->rpm_status = RPM_ACTIVE; in blk_pre_runtime_suspend()
97 pm_runtime_mark_last_busy(q->dev); in blk_pre_runtime_suspend()
98 spin_unlock_irq(&q->queue_lock); in blk_pre_runtime_suspend()
108 * blk_post_runtime_suspend - Post runtime suspend processing
122 if (!q->dev) in blk_post_runtime_suspend()
125 spin_lock_irq(&q->queue_lock); in blk_post_runtime_suspend()
127 q->rpm_status = RPM_SUSPENDED; in blk_post_runtime_suspend()
129 q->rpm_status = RPM_ACTIVE; in blk_post_runtime_suspend()
130 pm_runtime_mark_last_busy(q->dev); in blk_post_runtime_suspend()
132 spin_unlock_irq(&q->queue_lock); in blk_post_runtime_suspend()
140 * blk_pre_runtime_resume - Pre runtime resume processing
152 if (!q->dev) in blk_pre_runtime_resume()
155 spin_lock_irq(&q->queue_lock); in blk_pre_runtime_resume()
156 q->rpm_status = RPM_RESUMING; in blk_pre_runtime_resume()
157 spin_unlock_irq(&q->queue_lock); in blk_pre_runtime_resume()
162 * blk_post_runtime_resume - Post runtime resume processing
167 * of whether the device's runtime-resume succeeded; even if it failed the
171 * runtime_resume callback to correct queue runtime PM status and re-enable
178 if (!q->dev) in blk_post_runtime_resume()
181 spin_lock_irq(&q->queue_lock); in blk_post_runtime_resume()
182 old_status = q->rpm_status; in blk_post_runtime_resume()
183 q->rpm_status = RPM_ACTIVE; in blk_post_runtime_resume()
184 pm_runtime_mark_last_busy(q->dev); in blk_post_runtime_resume()
185 pm_request_autosuspend(q->dev); in blk_post_runtime_resume()
186 spin_unlock_irq(&q->queue_lock); in blk_post_runtime_resume()