mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ho Jie Feng <hjf3108@gmail.com>
To: Ulf Hansson <ulfh@kernel.org>
Cc: Maxim Levitsky <maximlevitsky@gmail.com>,
	Alex Dubov <oakad@yahoo.com>,
	linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ho Jie Feng <hjf3108@gmail.com>, Jens Axboe <axboe@kernel.dk>,
	Hannes Reinecke <hare@suse.com>, Omar Sandoval <osandov@fb.com>
Subject: [PATCH 2/5] memstick: mspro_block: wait for running dispatches in mspro_block_stop()
Date: Mon,  9 Nov 2026 23:38:01 +0800	[thread overview]
Message-ID: <20261109153832.7377-2-hjf3108@gmail.com> (raw)
In-Reply-To: <20261109153510.7161-1-hjf3108@gmail.com>

mspro_block_stop() only calls blk_mq_stop_hw_queues() once it sees that
msb->block_req is NULL. That marks the queues stopped so that no new
dispatch starts, but does not wait for dispatches that are already
running. In this case, a request can start just after
mspro_block_stop() has returned, causing a race condition.

Stop the queues before checking msb->block_req, and use
blk_mq_wait_quiesce_done() to wait for running ->queue_rq() calls to
return. The existing loop then waits for the current request to finish
before mspro_block_stop() returns.

Fixes: d0be12274dad ("mspro_block: convert to blk-mq")
Signed-off-by: Ho Jie Feng <hjf3108@gmail.com>
---
 drivers/memstick/core/mspro_block.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c
index fe38b42431219..215f4c3759c41 100644
--- a/drivers/memstick/core/mspro_block.c
+++ b/drivers/memstick/core/mspro_block.c
@@ -727,12 +727,13 @@ static void mspro_block_stop(struct memstick_dev *card)
 	int rc = 0;
 	unsigned long flags;
 
+	blk_mq_stop_hw_queues(msb->queue);
+	blk_mq_wait_quiesce_done(&msb->tag_set);
+
 	while (1) {
 		spin_lock_irqsave(&msb->q_lock, flags);
-		if (!msb->block_req) {
-			blk_mq_stop_hw_queues(msb->queue);
+		if (!msb->block_req)
 			rc = 1;
-		}
 		spin_unlock_irqrestore(&msb->q_lock, flags);
 
 		if (rc)
-- 
2.56.0


  parent reply	other threads:[~2026-11-09 15:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 15:34 [PATCH 0/5] memstick: fixes for mspro_block and ms_block Ho Jie Feng
2026-11-09 15:38 ` [PATCH 1/5] memstick: mspro_block: don't hand a finished request back to the host Ho Jie Feng
2026-11-09 15:38 ` Ho Jie Feng [this message]
2026-11-09 15:38 ` [PATCH 3/5] memstick: ms_block: don't erase the old block of an unmapped LBA Ho Jie Feng
2026-11-09 15:38 ` [PATCH 4/5] memstick: ms_block: keep the power off during a full msb_reset() Ho Jie Feng
2026-11-09 15:38 ` [PATCH 5/5] memstick: ms_block: add the missing newline to the parallel switch error Ho Jie Feng

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=20261109153832.7377-2-hjf3108@gmail.com \
    --to=hjf3108@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=hare@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=maximlevitsky@gmail.com \
    --cc=oakad@yahoo.com \
    --cc=osandov@fb.com \
    --cc=ulfh@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

all inboxes | Powered by JetHome®