Skip to content

Commit 26caddf

Browse files
ahunter6storulf
authored andcommitted
mmc: block: Fix unsupported parallel dispatch of requests
The mmc block driver does not support parallel dispatch of requests. In normal circumstances, all requests are anyway funneled through a single work item, so parallel dispatch never happens. However it can happen if there is no elevator. Fix that by detecting if a dispatch is in progress and returning busy (BLK_STS_RESOURCE) in that case Fixes: 8119697 ("mmc: block: Add blk-mq support") Cc: [email protected] # v4.16+ Signed-off-by: Adrian Hunter <[email protected]> Signed-off-by: Ulf Hansson <[email protected]>
1 parent 17e96d8 commit 26caddf

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

drivers/mmc/core/queue.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,6 @@ static void mmc_mq_exit_request(struct blk_mq_tag_set *set, struct request *req,
238238
mmc_exit_request(mq->queue, req);
239239
}
240240

241-
/*
242-
* We use BLK_MQ_F_BLOCKING and have only 1 hardware queue, which means requests
243-
* will not be dispatched in parallel.
244-
*/
245241
static blk_status_t mmc_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
246242
const struct blk_mq_queue_data *bd)
247243
{
@@ -264,7 +260,7 @@ static blk_status_t mmc_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
264260

265261
spin_lock_irq(q->queue_lock);
266262

267-
if (mq->recovery_needed) {
263+
if (mq->recovery_needed || mq->busy) {
268264
spin_unlock_irq(q->queue_lock);
269265
return BLK_STS_RESOURCE;
270266
}
@@ -291,6 +287,9 @@ static blk_status_t mmc_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
291287
break;
292288
}
293289

290+
/* Parallel dispatch of requests is not supported at the moment */
291+
mq->busy = true;
292+
294293
mq->in_flight[issue_type] += 1;
295294
get_card = (mmc_tot_in_flight(mq) == 1);
296295
cqe_retune_ok = (mmc_cqe_qcnt(mq) == 1);
@@ -333,9 +332,12 @@ static blk_status_t mmc_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
333332
mq->in_flight[issue_type] -= 1;
334333
if (mmc_tot_in_flight(mq) == 0)
335334
put_card = true;
335+
mq->busy = false;
336336
spin_unlock_irq(q->queue_lock);
337337
if (put_card)
338338
mmc_put_card(card, &mq->ctx);
339+
} else {
340+
WRITE_ONCE(mq->busy, false);
339341
}
340342

341343
return ret;

drivers/mmc/core/queue.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ struct mmc_queue {
8181
unsigned int cqe_busy;
8282
#define MMC_CQE_DCMD_BUSY BIT(0)
8383
#define MMC_CQE_QUEUE_FULL BIT(1)
84+
bool busy;
8485
bool use_cqe;
8586
bool recovery_needed;
8687
bool in_recovery;

0 commit comments

Comments
 (0)