[PATCH 2/5] memstick: mspro_block: wait for running dispatches in mspro_block_stop()
From: Ho Jie Feng
Date: Mon Nov 09 2026 - 10:39:07 EST
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@xxxxxxxxx>
---
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