From: Christoph Hellwig <hch@lst.de>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: linux-mmc@vger.kernel.org, linux-block@vger.kernel.org
Subject: [PATCH 2/2] mmc: switch to blk_mq_alloc_disk
Date: Wed, 16 Jun 2021 07:39:34 +0200 [thread overview]
Message-ID: <20210616053934.880951-3-hch@lst.de> (raw)
In-Reply-To: <20210616053934.880951-1-hch@lst.de>
Use the blk_mq_alloc_disk to allocate the request_queue and gendisk
together.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/mmc/core/block.c | 14 +++-----------
drivers/mmc/core/queue.c | 23 ++++++++++-------------
drivers/mmc/core/queue.h | 2 +-
3 files changed, 14 insertions(+), 25 deletions(-)
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 947624e76c33..6652e1f1d4b2 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -2310,27 +2310,21 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
*/
md->read_only = mmc_blk_readonly(card);
- md->disk = alloc_disk(perdev_minors);
- if (md->disk == NULL) {
- ret = -ENOMEM;
+ md->disk = mmc_init_queue(&md->queue, card);
+ if (IS_ERR(md->disk)) {
+ ret = PTR_ERR(md->disk);
goto err_kfree;
}
INIT_LIST_HEAD(&md->part);
INIT_LIST_HEAD(&md->rpmbs);
md->usage = 1;
-
- ret = mmc_init_queue(&md->queue, card);
- if (ret)
- goto err_putdisk;
-
md->queue.blkdata = md;
md->disk->major = MMC_BLOCK_MAJOR;
md->disk->first_minor = devidx * perdev_minors;
md->disk->fops = &mmc_bdops;
md->disk->private_data = md;
- md->disk->queue = md->queue.queue;
md->parent = parent;
set_disk_ro(md->disk, md->read_only || default_ro);
md->disk->flags = GENHD_FL_EXT_DEVT;
@@ -2379,8 +2373,6 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
return md;
- err_putdisk:
- put_disk(md->disk);
err_kfree:
kfree(md);
out:
diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c
index d600e0a4a460..cc3261777637 100644
--- a/drivers/mmc/core/queue.c
+++ b/drivers/mmc/core/queue.c
@@ -424,9 +424,10 @@ static inline bool mmc_merge_capable(struct mmc_host *host)
*
* Initialise a MMC card request queue.
*/
-int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card)
+struct gendisk *mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card)
{
struct mmc_host *host = card->host;
+ struct gendisk *disk;
int ret;
mq->card = card;
@@ -464,26 +465,22 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card)
ret = blk_mq_alloc_tag_set(&mq->tag_set);
if (ret)
- return ret;
+ return ERR_PTR(ret);
+
- mq->queue = blk_mq_init_queue(&mq->tag_set);
- if (IS_ERR(mq->queue)) {
- ret = PTR_ERR(mq->queue);
- goto free_tag_set;
+ disk = blk_mq_alloc_disk(&mq->tag_set, mq);
+ if (IS_ERR(disk)) {
+ blk_mq_free_tag_set(&mq->tag_set);
+ return disk;
}
+ mq->queue = disk->queue;
if (mmc_host_is_spi(host) && host->use_spi_crc)
blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, mq->queue);
-
- mq->queue->queuedata = mq;
blk_queue_rq_timeout(mq->queue, 60 * HZ);
mmc_setup_queue(mq, card);
- return 0;
-
-free_tag_set:
- blk_mq_free_tag_set(&mq->tag_set);
- return ret;
+ return disk;
}
void mmc_queue_suspend(struct mmc_queue *mq)
diff --git a/drivers/mmc/core/queue.h b/drivers/mmc/core/queue.h
index 3319d8ab57d0..9ade3bcbb714 100644
--- a/drivers/mmc/core/queue.h
+++ b/drivers/mmc/core/queue.h
@@ -94,7 +94,7 @@ struct mmc_queue {
struct work_struct complete_work;
};
-extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *);
+struct gendisk *mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card);
extern void mmc_cleanup_queue(struct mmc_queue *);
extern void mmc_queue_suspend(struct mmc_queue *);
extern void mmc_queue_resume(struct mmc_queue *);
--
2.30.2
next prev parent reply other threads:[~2021-06-16 5:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-16 5:39 convert the mmc driver to use blk_mq_alloc_disk Christoph Hellwig
2021-06-16 5:39 ` [PATCH 1/2] mmc: remove an extra blk_{get,put}_queue pair Christoph Hellwig
2021-06-17 9:55 ` Ulf Hansson
2021-06-16 5:39 ` Christoph Hellwig [this message]
2021-06-17 9:55 ` [PATCH 2/2] mmc: switch to blk_mq_alloc_disk Ulf Hansson
[not found] ` <CGME20210621062208eucas1p2949c830b948c3cf7b3d636c5c5746753@eucas1p2.samsung.com>
2021-06-21 6:22 ` Marek Szyprowski
2021-06-21 6:59 ` Christoph Hellwig
2021-06-21 7:53 ` Marek Szyprowski
2021-06-17 9:58 ` convert the mmc driver to use blk_mq_alloc_disk Ulf Hansson
2021-06-17 13:40 ` Jens Axboe
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=20210616053934.880951-3-hch@lst.de \
--to=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.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;
as well as URLs for NNTP newsgroup(s).