aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2018-08-21 08:05:55 -0400
committerUlf Hansson <ulf.hansson@linaro.org>2018-08-21 10:12:41 -0400
commit26caddf274cf1e89fd4ce44ab2b8dbc7a7f97681 (patch)
tree52b81204031618043211b80dc1c5adc0fa880e7d
parent17e96d8516e31c3cb52cb8e2ee79d1d2e6948c11 (diff)
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: 81196976ed94 ("mmc: block: Add blk-mq support") Cc: stable@vger.kernel.org # v4.16+ Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r--drivers/mmc/core/queue.c12
-rw-r--r--drivers/mmc/core/queue.h1
2 files changed, 8 insertions, 5 deletions
diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c
index 648eb6743ed5..6edffeed9953 100644
--- a/drivers/mmc/core/queue.c
+++ b/drivers/mmc/core/queue.c
@@ -238,10 +238,6 @@ static void mmc_mq_exit_request(struct blk_mq_tag_set *set, struct request *req,
238 mmc_exit_request(mq->queue, req); 238 mmc_exit_request(mq->queue, req);
239} 239}
240 240
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 */
245static blk_status_t mmc_mq_queue_rq(struct blk_mq_hw_ctx *hctx, 241static blk_status_t mmc_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
246 const struct blk_mq_queue_data *bd) 242 const struct blk_mq_queue_data *bd)
247{ 243{
@@ -264,7 +260,7 @@ static blk_status_t mmc_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
264 260
265 spin_lock_irq(q->queue_lock); 261 spin_lock_irq(q->queue_lock);
266 262
267 if (mq->recovery_needed) { 263 if (mq->recovery_needed || mq->busy) {
268 spin_unlock_irq(q->queue_lock); 264 spin_unlock_irq(q->queue_lock);
269 return BLK_STS_RESOURCE; 265 return BLK_STS_RESOURCE;
270 } 266 }
@@ -291,6 +287,9 @@ static blk_status_t mmc_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
291 break; 287 break;
292 } 288 }
293 289
290 /* Parallel dispatch of requests is not supported at the moment */
291 mq->busy = true;
292
294 mq->in_flight[issue_type] += 1; 293 mq->in_flight[issue_type] += 1;
295 get_card = (mmc_tot_in_flight(mq) == 1); 294 get_card = (mmc_tot_in_flight(mq) == 1);
296 cqe_retune_ok = (mmc_cqe_qcnt(mq) == 1); 295 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,
333 mq->in_flight[issue_type] -= 1; 332 mq->in_flight[issue_type] -= 1;
334 if (mmc_tot_in_flight(mq) == 0) 333 if (mmc_tot_in_flight(mq) == 0)
335 put_card = true; 334 put_card = true;
335 mq->busy = false;
336 spin_unlock_irq(q->queue_lock); 336 spin_unlock_irq(q->queue_lock);
337 if (put_card) 337 if (put_card)
338 mmc_put_card(card, &mq->ctx); 338 mmc_put_card(card, &mq->ctx);
339 } else {
340 WRITE_ONCE(mq->busy, false);
339 } 341 }
340 342
341 return ret; 343 return ret;
diff --git a/drivers/mmc/core/queue.h b/drivers/mmc/core/queue.h
index 17e59d50b496..9bf3c9245075 100644
--- a/drivers/mmc/core/queue.h
+++ b/drivers/mmc/core/queue.h
@@ -81,6 +81,7 @@ struct mmc_queue {
81 unsigned int cqe_busy; 81 unsigned int cqe_busy;
82#define MMC_CQE_DCMD_BUSY BIT(0) 82#define MMC_CQE_DCMD_BUSY BIT(0)
83#define MMC_CQE_QUEUE_FULL BIT(1) 83#define MMC_CQE_QUEUE_FULL BIT(1)
84 bool busy;
84 bool use_cqe; 85 bool use_cqe;
85 bool recovery_needed; 86 bool recovery_needed;
86 bool in_recovery; 87 bool in_recovery;