diff options
| author | Stanley Jhu <stanleyjhu@google.com> | 2026-11-04 19:27:44 +0800 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2026-11-18 09:04:51 -0700 |
| commit | 657d7c48b84f2ef0bf885b47cf2318823bc72970 (patch) | |
| tree | 6968408f20e66bc86ac1feae3f928970ad905e38 /kernel | |
| parent | c4d97ab7792e11a7e83c475505c2cbefd74a921a (diff) | |
block: Keep RPM_ACTIVE in blk_pre_runtime_resume() when already active
Since commit eef1d74bf88f ("PM: runtime: Only set runtime_error on
suspend callback failures"), a failed runtime resume leaves
dev->power.runtime_error at 0 with runtime_status set to RPM_SUSPENDED,
so later runtime resume requests run sdev_runtime_resume() again:
1. A runtime suspend increments q->pm_only from 0 to 1 and sets
q->rpm_status to RPM_SUSPENDED.
2. The first runtime resume fails in the driver callback, and
blk_post_runtime_resume() sets q->rpm_status to RPM_ACTIVE and calls
blk_clear_pm_only(), decrementing q->pm_only from 1 to 0 so recovery
commands can enter the queue (intended since
commit 6e1fcab00a23 ("scsi: block: pm: Always set request queue
runtime active in blk_post_runtime_resume()")).
3. A retried runtime resume calls blk_pre_runtime_resume(), which
overwrites q->rpm_status from RPM_ACTIVE to RPM_RESUMING, so
blk_post_runtime_resume() sees old_status != RPM_ACTIVE and calls
blk_clear_pm_only() a second time without a matching
blk_set_pm_only().
4. q->pm_only underflows from 0 to -1 (triggering WARN_ON_ONCE in
blk_clear_pm_only()), blocking non-PM requests in blk_queue_enter()
and __bio_queue_enter() while the device is RPM_ACTIVE, and the next
runtime suspend increments q->pm_only from -1 to 0, letting non-PM
requests dispatch while RPM_SUSPENDED. This hits the UFS device
well-known LUN by default and SCSI disks with
manage_runtime_start_stop enabled (ATA and FireWire sbp2 defaults).
Transition q->rpm_status to RPM_RESUMING in blk_pre_runtime_resume()
only when it is RPM_SUSPENDED, and call blk_clear_pm_only() in
blk_post_runtime_resume() only when old_status is RPM_RESUMING, pairing
each clear with a completed runtime suspend.
Tested on QEMU ARM64 UFS in SDB and MCQ modes by injecting
runtime-resume START STOP UNIT failures on the UFS device well-known
LUN, confirming zero pm_only underflows and balanced runtime PM cycles.
Fixes: eef1d74bf88f ("PM: runtime: Only set runtime_error on suspend callback failures")
Cc: stable@vger.kernel.org # v7.3+
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Stanley Jhu <stanleyjhu@google.com>
Acked-by: Rafael J. Wysocki (Intel) <rafael@kernel.org>
Link: https://patch.msgid.link/20261104112744.1630864-1-stanleyjhu@google.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'kernel')
0 files changed, 0 insertions, 0 deletions
