linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* convert the mmc driver to use blk_mq_alloc_disk
@ 2021-06-16  5:39 Christoph Hellwig
  2021-06-16  5:39 ` [PATCH 1/2] mmc: remove an extra blk_{get,put}_queue pair Christoph Hellwig
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Christoph Hellwig @ 2021-06-16  5:39 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc, linux-block

Hi Ulf,

can you take a look at this series which converts the mmc driver to the
new blk_mq_alloc_disk interface.  It is based upon Jens' for-5.14/block
or for-next trees.

Diffstat:
 block.c |   28 ++++------------------------
 queue.c |   23 ++++++++++-------------
 queue.h |    2 +-
 3 files changed, 15 insertions(+), 38 deletions(-)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/2] mmc: remove an extra blk_{get,put}_queue pair
  2021-06-16  5:39 convert the mmc driver to use blk_mq_alloc_disk Christoph Hellwig
@ 2021-06-16  5:39 ` Christoph Hellwig
  2021-06-17  9:55   ` Ulf Hansson
  2021-06-16  5:39 ` [PATCH 2/2] mmc: switch to blk_mq_alloc_disk Christoph Hellwig
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Christoph Hellwig @ 2021-06-16  5:39 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc, linux-block

The gendisk already acquires a reference to the queue when add_disk
is called, which dropped on put_disk.  So remove the superflous
extra refcounting.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/mmc/core/block.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 689eb9afeeed..947624e76c33 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -201,7 +201,7 @@ static void mmc_blk_put(struct mmc_blk_data *md)
 	md->usage--;
 	if (md->usage == 0) {
 		int devidx = mmc_get_devidx(md->disk);
-		blk_put_queue(md->queue.queue);
+
 		ida_simple_remove(&mmc_blk_ida, devidx);
 		put_disk(md->disk);
 		kfree(md);
@@ -2326,18 +2326,6 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
 
 	md->queue.blkdata = md;
 
-	/*
-	 * Keep an extra reference to the queue so that we can shutdown the
-	 * queue (i.e. call blk_cleanup_queue()) while there are still
-	 * references to the 'md'. The corresponding blk_put_queue() is in
-	 * mmc_blk_put().
-	 */
-	if (!blk_get_queue(md->queue.queue)) {
-		mmc_cleanup_queue(&md->queue);
-		ret = -ENODEV;
-		goto err_putdisk;
-	}
-
 	md->disk->major	= MMC_BLOCK_MAJOR;
 	md->disk->first_minor = devidx * perdev_minors;
 	md->disk->fops = &mmc_bdops;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/2] mmc: switch to blk_mq_alloc_disk
  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-16  5:39 ` Christoph Hellwig
  2021-06-17  9:55   ` Ulf Hansson
       [not found]   ` <CGME20210621062208eucas1p2949c830b948c3cf7b3d636c5c5746753@eucas1p2.samsung.com>
  2021-06-17  9:58 ` convert the mmc driver to use blk_mq_alloc_disk Ulf Hansson
  2021-06-17 13:40 ` Jens Axboe
  3 siblings, 2 replies; 10+ messages in thread
From: Christoph Hellwig @ 2021-06-16  5:39 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc, linux-block

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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] mmc: remove an extra blk_{get,put}_queue pair
  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
  0 siblings, 0 replies; 10+ messages in thread
From: Ulf Hansson @ 2021-06-17  9:55 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-mmc, linux-block

On Wed, 16 Jun 2021 at 07:40, Christoph Hellwig <hch@lst.de> wrote:
>
> The gendisk already acquires a reference to the queue when add_disk
> is called, which dropped on put_disk.  So remove the superflous
> extra refcounting.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Nice cleanup!

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe


> ---
>  drivers/mmc/core/block.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)
>
> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
> index 689eb9afeeed..947624e76c33 100644
> --- a/drivers/mmc/core/block.c
> +++ b/drivers/mmc/core/block.c
> @@ -201,7 +201,7 @@ static void mmc_blk_put(struct mmc_blk_data *md)
>         md->usage--;
>         if (md->usage == 0) {
>                 int devidx = mmc_get_devidx(md->disk);
> -               blk_put_queue(md->queue.queue);
> +
>                 ida_simple_remove(&mmc_blk_ida, devidx);
>                 put_disk(md->disk);
>                 kfree(md);
> @@ -2326,18 +2326,6 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
>
>         md->queue.blkdata = md;
>
> -       /*
> -        * Keep an extra reference to the queue so that we can shutdown the
> -        * queue (i.e. call blk_cleanup_queue()) while there are still
> -        * references to the 'md'. The corresponding blk_put_queue() is in
> -        * mmc_blk_put().
> -        */
> -       if (!blk_get_queue(md->queue.queue)) {
> -               mmc_cleanup_queue(&md->queue);
> -               ret = -ENODEV;
> -               goto err_putdisk;
> -       }
> -
>         md->disk->major = MMC_BLOCK_MAJOR;
>         md->disk->first_minor = devidx * perdev_minors;
>         md->disk->fops = &mmc_bdops;
> --
> 2.30.2
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] mmc: switch to blk_mq_alloc_disk
  2021-06-16  5:39 ` [PATCH 2/2] mmc: switch to blk_mq_alloc_disk Christoph Hellwig
@ 2021-06-17  9:55   ` Ulf Hansson
       [not found]   ` <CGME20210621062208eucas1p2949c830b948c3cf7b3d636c5c5746753@eucas1p2.samsung.com>
  1 sibling, 0 replies; 10+ messages in thread
From: Ulf Hansson @ 2021-06-17  9:55 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-mmc, linux-block

On Wed, 16 Jun 2021 at 07:40, Christoph Hellwig <hch@lst.de> wrote:
>
> Use the blk_mq_alloc_disk to allocate the request_queue and gendisk
> together.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Nice cleanup!

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe


> ---
>  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
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: convert the mmc driver to use blk_mq_alloc_disk
  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-16  5:39 ` [PATCH 2/2] mmc: switch to blk_mq_alloc_disk Christoph Hellwig
@ 2021-06-17  9:58 ` Ulf Hansson
  2021-06-17 13:40 ` Jens Axboe
  3 siblings, 0 replies; 10+ messages in thread
From: Ulf Hansson @ 2021-06-17  9:58 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe; +Cc: linux-mmc, linux-block

+ Jens

On Wed, 16 Jun 2021 at 07:39, Christoph Hellwig <hch@lst.de> wrote:
>
> Hi Ulf,
>
> can you take a look at this series which converts the mmc driver to the
> new blk_mq_alloc_disk interface.  It is based upon Jens' for-5.14/block
> or for-next trees.

I don't see any issues with queuing this via Jens' tree, as I have
only a few minor changes queued in my mmc tree that touch the
corresponding files. None of which should cause a merge conflict, I
think.

>
> Diffstat:
>  block.c |   28 ++++------------------------
>  queue.c |   23 ++++++++++-------------
>  queue.h |    2 +-
>  3 files changed, 15 insertions(+), 38 deletions(-)

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: convert the mmc driver to use blk_mq_alloc_disk
  2021-06-16  5:39 convert the mmc driver to use blk_mq_alloc_disk Christoph Hellwig
                   ` (2 preceding siblings ...)
  2021-06-17  9:58 ` convert the mmc driver to use blk_mq_alloc_disk Ulf Hansson
@ 2021-06-17 13:40 ` Jens Axboe
  3 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2021-06-17 13:40 UTC (permalink / raw)
  To: Christoph Hellwig, Ulf Hansson; +Cc: linux-mmc, linux-block

On 6/15/21 11:39 PM, Christoph Hellwig wrote:
> Hi Ulf,
> 
> can you take a look at this series which converts the mmc driver to the
> new blk_mq_alloc_disk interface.  It is based upon Jens' for-5.14/block
> or for-next trees.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] mmc: switch to blk_mq_alloc_disk
       [not found]   ` <CGME20210621062208eucas1p2949c830b948c3cf7b3d636c5c5746753@eucas1p2.samsung.com>
@ 2021-06-21  6:22     ` Marek Szyprowski
  2021-06-21  6:59       ` Christoph Hellwig
  0 siblings, 1 reply; 10+ messages in thread
From: Marek Szyprowski @ 2021-06-21  6:22 UTC (permalink / raw)
  To: Christoph Hellwig, Ulf Hansson; +Cc: linux-mmc, linux-block

Hi

On 16.06.2021 07:39, Christoph Hellwig wrote:
> Use the blk_mq_alloc_disk to allocate the request_queue and gendisk
> together.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

This patch landed recently in linux-next as commit 281ea6a5bfdc ("mmc: 
switch to blk_mq_alloc_disk"). It triggers the following warning during 
boot on all my systems with MMC devices:

------------[ cut here ]------------
WARNING: CPU: 0 PID: 10 at block/genhd.c:491 __device_add_disk+0x4e8/0x630
Modules linked in:
CPU: 0 PID: 10 Comm: kworker/0:1 Not tainted 
5.13.0-rc3-00090-g281ea6a5bfdc #3542
Hardware name: Samsung Exynos (Flattened Device Tree)
Workqueue: events_freezable mmc_rescan
[<c0111844>] (unwind_backtrace) from [<c010d014>] (show_stack+0x10/0x14)
[<c010d014>] (show_stack) from [<c0b6f84c>] (dump_stack+0xa4/0xc4)
[<c0b6f84c>] (dump_stack) from [<c0127630>] (__warn+0x118/0x11c)
[<c0127630>] (__warn) from [<c01276e8>] (warn_slowpath_fmt+0xb4/0xbc)
[<c01276e8>] (warn_slowpath_fmt) from [<c052a52c>] 
(__device_add_disk+0x4e8/0x630)
[<c052a52c>] (__device_add_disk) from [<c08a8e10>] (mmc_add_disk+0x24/0x120)
[<c08a8e10>] (mmc_add_disk) from [<c08a9e68>] (mmc_blk_probe+0x420/0x65c)
[<c08a9e68>] (mmc_blk_probe) from [<c06bece4>] (really_probe+0x250/0x4dc)
[<c06bece4>] (really_probe) from [<c06beff4>] 
(driver_probe_device+0x84/0x1e4)
[<c06beff4>] (driver_probe_device) from [<c06bcc70>] 
(bus_for_each_drv+0x78/0xbc)
[<c06bcc70>] (bus_for_each_drv) from [<c06be9f4>] 
(__device_attach+0xe8/0x180)
[<c06be9f4>] (__device_attach) from [<c06bda1c>] 
(bus_probe_device+0x88/0x90)
[<c06bda1c>] (bus_probe_device) from [<c06bb5f0>] (device_add+0x4c8/0x874)
[<c06bb5f0>] (device_add) from [<c089ac6c>] (mmc_add_card+0x110/0x2d0)
[<c089ac6c>] (mmc_add_card) from [<c089ebd8>] (mmc_attach_mmc+0xc8/0x180)
[<c089ebd8>] (mmc_attach_mmc) from [<c089a5c4>] (mmc_rescan+0x2ec/0x334)
[<c089a5c4>] (mmc_rescan) from [<c014a994>] (process_one_work+0x30c/0x884)
[<c014a994>] (process_one_work) from [<c014af64>] (worker_thread+0x58/0x594)
[<c014af64>] (worker_thread) from [<c0151f34>] (kthread+0x154/0x19c)
[<c0151f34>] (kthread) from [<c010011c>] (ret_from_fork+0x14/0x38)
Exception stack(0xc1d25fb0 to 0xc1d25ff8)
...
irq event stamp: 3653
hardirqs last  enabled at (3667): [<c0100b4c>] __irq_svc+0x8c/0xb0
hardirqs last disabled at (3678): [<c0b749c4>] __schedule+0x54c/0x9dc
softirqs last  enabled at (3648): [<c0101790>] __do_softirq+0x528/0x63c
softirqs last disabled at (3641): [<c01311b8>] irq_exit+0x214/0x220
---[ end trace e60288107691b657 ]---

It looks that something is missing in this conversion.

> ---
>   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 *);

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] mmc: switch to blk_mq_alloc_disk
  2021-06-21  6:22     ` Marek Szyprowski
@ 2021-06-21  6:59       ` Christoph Hellwig
  2021-06-21  7:53         ` Marek Szyprowski
  0 siblings, 1 reply; 10+ messages in thread
From: Christoph Hellwig @ 2021-06-21  6:59 UTC (permalink / raw)
  To: Marek Szyprowski; +Cc: Christoph Hellwig, Ulf Hansson, linux-mmc, linux-block

On Mon, Jun 21, 2021 at 08:22:07AM +0200, Marek Szyprowski wrote:
> Hi
> 
> On 16.06.2021 07:39, Christoph Hellwig wrote:
> > Use the blk_mq_alloc_disk to allocate the request_queue and gendisk
> > together.
> >
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> This patch landed recently in linux-next as commit 281ea6a5bfdc ("mmc: 
> switch to blk_mq_alloc_disk"). It triggers the following warning during 
> boot on all my systems with MMC devices:

Please try this, I lost this hunk in the final cleanup, sorry:

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index e7f89cbf9232..9890a1532cb0 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -2331,6 +2331,7 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
 	md->queue.blkdata = md;
 
 	md->disk->major	= MMC_BLOCK_MAJOR;
+	md->disk->minors = perdev_minors;
 	md->disk->first_minor = devidx * perdev_minors;
 	md->disk->fops = &mmc_bdops;
 	md->disk->private_data = md;

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] mmc: switch to blk_mq_alloc_disk
  2021-06-21  6:59       ` Christoph Hellwig
@ 2021-06-21  7:53         ` Marek Szyprowski
  0 siblings, 0 replies; 10+ messages in thread
From: Marek Szyprowski @ 2021-06-21  7:53 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Ulf Hansson, linux-mmc, linux-block

Hi Christoph,

On 21.06.2021 08:59, Christoph Hellwig wrote:
> On Mon, Jun 21, 2021 at 08:22:07AM +0200, Marek Szyprowski wrote:
>> On 16.06.2021 07:39, Christoph Hellwig wrote:
>>> Use the blk_mq_alloc_disk to allocate the request_queue and gendisk
>>> together.
>>>
>>> Signed-off-by: Christoph Hellwig <hch@lst.de>
>> This patch landed recently in linux-next as commit 281ea6a5bfdc ("mmc:
>> switch to blk_mq_alloc_disk"). It triggers the following warning during
>> boot on all my systems with MMC devices:
> Please try this, I lost this hunk in the final cleanup, sorry:

No problem. Right, it fixes the issue. Feel free to add:

Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
> index e7f89cbf9232..9890a1532cb0 100644
> --- a/drivers/mmc/core/block.c
> +++ b/drivers/mmc/core/block.c
> @@ -2331,6 +2331,7 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
>   	md->queue.blkdata = md;
>   
>   	md->disk->major	= MMC_BLOCK_MAJOR;
> +	md->disk->minors = perdev_minors;
>   	md->disk->first_minor = devidx * perdev_minors;
>   	md->disk->fops = &mmc_bdops;
>   	md->disk->private_data = md;
>
Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-06-21  7:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 2/2] mmc: switch to blk_mq_alloc_disk Christoph Hellwig
2021-06-17  9:55   ` 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

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).