From: YangYang <yang.yang@vivo.com>
To: Bart Van Assche <bvanassche@acm.org>,
"Rafael J. Wysocki" <rafael@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>, Pavel Machek <pavel@kernel.org>,
Len Brown <lenb@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Danilo Krummrich <dakr@kernel.org>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-pm@vger.kernel.org
Subject: Re: [PATCH 1/2] PM: runtime: Fix I/O hang due to race between resume and runtime disable
Date: Thu, 27 Nov 2025 19:29:31 +0800 [thread overview]
Message-ID: <4f4dea0a-21b1-438c-94ae-9a785ad42569@vivo.com> (raw)
In-Reply-To: <6df79ec0-f5b3-4d75-95b1-03e488d45e7f@acm.org>
On 2025/11/27 2:40, Bart Van Assche wrote:
> On 11/26/25 7:41 AM, Rafael J. Wysocki wrote:
>> As it stands, you have a basic problem with respect to system
>> suspend/hibernation. As I said before, the PM workqueue is frozen
>> during system suspend/hibernation transitions, so waiting for an async
>> resume request to complete then is pointless.
>
> Agreed. I noticed that any attempt to call request_firmware() from
> driver system resume callback functions causes a deadlock if these
> calls happen before the block device has been resumed.
>
> Thanks,
>
> Bart.
Does this patch look reasonable to you? It hasn't been fully tested
yet, but the resume is now performed synchronously.
diff --git a/block/blk-core.c b/block/blk-core.c
index 66fb2071d..041d29ba4 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -323,12 +323,15 @@ int blk_queue_enter(struct request_queue *q,
blk_mq_req_flags_t flags)
* reordered.
*/
smp_rmb();
- wait_event(q->mq_freeze_wq,
- (!q->mq_freeze_depth &&
- blk_pm_resume_queue(pm, q)) ||
- blk_queue_dying(q));
+check:
+ wait_event(q->mq_freeze_wq, !q->mq_freeze_depth);
+
if (blk_queue_dying(q))
return -ENODEV;
+ if (!blk_pm_resume_queue(pm, q)) {
+ pm_runtime_resume(q->dev);
+ goto check;
+ }
}
rwsem_acquire_read(&q->q_lockdep_map, 0, 0, _RET_IP_);
@@ -356,12 +359,15 @@ int __bio_queue_enter(struct request_queue *q,
struct bio *bio)
* reordered.
*/
smp_rmb();
- wait_event(q->mq_freeze_wq,
- (!q->mq_freeze_depth &&
- blk_pm_resume_queue(false, q)) ||
- test_bit(GD_DEAD, &disk->state));
+check:
+ wait_event(q->mq_freeze_wq, !q->mq_freeze_depth);
+
if (test_bit(GD_DEAD, &disk->state))
goto dead;
+ if (!blk_pm_resume_queue(false, q)) {
+ pm_runtime_resume(q->dev);
+ goto check;
+ }
}
rwsem_acquire_read(&q->io_lockdep_map, 0, 0, _RET_IP_);
diff --git a/block/blk-pm.h b/block/blk-pm.h
index 8a5a0d4b3..c28fad105 100644
--- a/block/blk-pm.h
+++ b/block/blk-pm.h
@@ -12,7 +12,6 @@ static inline int blk_pm_resume_queue(const bool pm,
struct request_queue *q)
return 1; /* Nothing to do */
if (pm && q->rpm_status != RPM_SUSPENDED)
return 1; /* Request allowed */
- pm_request_resume(q->dev);
return 0;
}
next prev parent reply other threads:[~2025-11-27 11:29 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 10:16 [PATCH 0/2] PM: runtime: Fix potential I/O hang Yang Yang
2025-11-26 10:16 ` [PATCH 1/2] PM: runtime: Fix I/O hang due to race between resume and runtime disable Yang Yang
2025-11-26 11:30 ` Rafael J. Wysocki
2025-11-26 11:59 ` YangYang
2025-11-26 12:36 ` Rafael J. Wysocki
2025-11-26 15:33 ` Bart Van Assche
2025-11-26 15:41 ` Rafael J. Wysocki
2025-11-26 18:40 ` Bart Van Assche
2025-11-27 11:29 ` YangYang [this message]
2025-11-27 12:44 ` Rafael J. Wysocki
2025-11-28 7:20 ` YangYang
2025-12-01 16:40 ` Bart Van Assche
2025-11-26 18:06 ` Bart Van Assche
2025-11-26 19:16 ` Rafael J. Wysocki
2025-11-26 19:34 ` Rafael J. Wysocki
2025-11-26 20:17 ` Rafael J. Wysocki
2025-11-26 21:10 ` Bart Van Assche
2025-11-26 21:30 ` Rafael J. Wysocki
2025-11-26 22:47 ` Bart Van Assche
2025-11-27 12:34 ` Rafael J. Wysocki
2025-12-01 9:46 ` YangYang
2025-12-01 12:56 ` YangYang
2025-12-01 18:55 ` Rafael J. Wysocki
2025-12-02 10:33 ` YangYang
2025-12-02 12:18 ` Rafael J. Wysocki
2025-12-01 18:47 ` Rafael J. Wysocki
2025-12-01 19:58 ` [PATCH v1] PM: sleep: Do not flag runtime PM workqueue as freezable Rafael J. Wysocki
2025-12-02 1:06 ` Bart Van Assche
2025-12-02 11:53 ` Rafael J. Wysocki
2025-12-02 13:29 ` Rafael J. Wysocki
2025-12-02 10:36 ` YangYang
2025-12-02 14:58 ` Ulf Hansson
2025-12-02 0:40 ` [PATCH 1/2] PM: runtime: Fix I/O hang due to race between resume and runtime disable Bart Van Assche
2025-12-02 12:14 ` Rafael J. Wysocki
2025-12-02 13:37 ` Rafael J. Wysocki
2025-12-05 15:24 ` [PATCH v2] PM: sleep: Do not flag runtime PM workqueue as freezable Rafael J. Wysocki
2025-12-05 19:10 ` Bart Van Assche
2025-12-07 11:23 ` Rafael J. Wysocki
2025-11-26 10:16 ` [PATCH 2/2] blk-mq: Fix I/O hang caused by incomplete device resume Yang Yang
2025-11-26 11:31 ` [PATCH 0/2] PM: runtime: Fix potential I/O hang Rafael J. Wysocki
2025-11-26 15:48 ` Bart Van Assche
2025-11-26 16:59 ` Rafael J. Wysocki
2025-11-26 17:21 ` Rafael J. Wysocki
2025-11-26 17:34 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4f4dea0a-21b1-438c-94ae-9a785ad42569@vivo.com \
--to=yang.yang@vivo.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=dakr@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=lenb@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@kernel.org \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox