Skip to content

Commit b061b32

Browse files
Christoph Hellwigaxboe
authored andcommitted
mmc: simplify queue initialization
Merge three functions initializing the queue into a single one, and drop an unused argument for it. Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 68fc68f commit b061b32

3 files changed

Lines changed: 31 additions & 59 deletions

File tree

‎drivers/mmc/core/block.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2334,7 +2334,7 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
23342334
INIT_LIST_HEAD(&md->rpmbs);
23352335
md->usage = 1;
23362336

2337-
ret = mmc_init_queue(&md->queue, card, &md->lock, subname);
2337+
ret = mmc_init_queue(&md->queue, card, &md->lock);
23382338
if (ret)
23392339
goto err_putdisk;
23402340

‎drivers/mmc/core/queue.c‎

Lines changed: 29 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -378,14 +378,37 @@ static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card)
378378
init_waitqueue_head(&mq->wait);
379379
}
380380

381-
static int mmc_mq_init_queue(struct mmc_queue *mq, int q_depth,
382-
const struct blk_mq_ops *mq_ops, spinlock_t *lock)
381+
/* Set queue depth to get a reasonable value for q->nr_requests */
382+
#define MMC_QUEUE_DEPTH 64
383+
384+
/**
385+
* mmc_init_queue - initialise a queue structure.
386+
* @mq: mmc queue
387+
* @card: mmc card to attach this queue
388+
* @lock: queue lock
389+
*
390+
* Initialise a MMC card request queue.
391+
*/
392+
int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,
393+
spinlock_t *lock)
383394
{
395+
struct mmc_host *host = card->host;
384396
int ret;
385397

398+
mq->card = card;
399+
mq->use_cqe = host->cqe_enabled;
400+
386401
memset(&mq->tag_set, 0, sizeof(mq->tag_set));
387-
mq->tag_set.ops = mq_ops;
388-
mq->tag_set.queue_depth = q_depth;
402+
mq->tag_set.ops = &mmc_mq_ops;
403+
/*
404+
* The queue depth for CQE must match the hardware because the request
405+
* tag is used to index the hardware queue.
406+
*/
407+
if (mq->use_cqe)
408+
mq->tag_set.queue_depth =
409+
min_t(int, card->ext_csd.cmdq_depth, host->cqe_qdepth);
410+
else
411+
mq->tag_set.queue_depth = MMC_QUEUE_DEPTH;
389412
mq->tag_set.numa_node = NUMA_NO_NODE;
390413
mq->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_SG_MERGE |
391414
BLK_MQ_F_BLOCKING;
@@ -405,66 +428,16 @@ static int mmc_mq_init_queue(struct mmc_queue *mq, int q_depth,
405428

406429
mq->queue->queue_lock = lock;
407430
mq->queue->queuedata = mq;
431+
blk_queue_rq_timeout(mq->queue, 60 * HZ);
408432

433+
mmc_setup_queue(mq, card);
409434
return 0;
410435

411436
free_tag_set:
412437
blk_mq_free_tag_set(&mq->tag_set);
413-
414438
return ret;
415439
}
416440

417-
/* Set queue depth to get a reasonable value for q->nr_requests */
418-
#define MMC_QUEUE_DEPTH 64
419-
420-
static int mmc_mq_init(struct mmc_queue *mq, struct mmc_card *card,
421-
spinlock_t *lock)
422-
{
423-
struct mmc_host *host = card->host;
424-
int q_depth;
425-
int ret;
426-
427-
/*
428-
* The queue depth for CQE must match the hardware because the request
429-
* tag is used to index the hardware queue.
430-
*/
431-
if (mq->use_cqe)
432-
q_depth = min_t(int, card->ext_csd.cmdq_depth, host->cqe_qdepth);
433-
else
434-
q_depth = MMC_QUEUE_DEPTH;
435-
436-
ret = mmc_mq_init_queue(mq, q_depth, &mmc_mq_ops, lock);
437-
if (ret)
438-
return ret;
439-
440-
blk_queue_rq_timeout(mq->queue, 60 * HZ);
441-
442-
mmc_setup_queue(mq, card);
443-
444-
return 0;
445-
}
446-
447-
/**
448-
* mmc_init_queue - initialise a queue structure.
449-
* @mq: mmc queue
450-
* @card: mmc card to attach this queue
451-
* @lock: queue lock
452-
* @subname: partition subname
453-
*
454-
* Initialise a MMC card request queue.
455-
*/
456-
int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,
457-
spinlock_t *lock, const char *subname)
458-
{
459-
struct mmc_host *host = card->host;
460-
461-
mq->card = card;
462-
463-
mq->use_cqe = host->cqe_enabled;
464-
465-
return mmc_mq_init(mq, card, lock);
466-
}
467-
468441
void mmc_queue_suspend(struct mmc_queue *mq)
469442
{
470443
blk_mq_quiesce_queue(mq->queue);

‎drivers/mmc/core/queue.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ struct mmc_queue {
9595
struct work_struct complete_work;
9696
};
9797

98-
extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
99-
const char *);
98+
extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *);
10099
extern void mmc_cleanup_queue(struct mmc_queue *);
101100
extern void mmc_queue_suspend(struct mmc_queue *);
102101
extern void mmc_queue_resume(struct mmc_queue *);

0 commit comments

Comments
 (0)