All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@collabora.com>
To: Sean Nyekjaer <sean@geanix.com>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Boris Brezillon <bbrezillon@kernel.org>,
	linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/4] mtd: mtdconcat: add suspend lock handling
Date: Mon, 25 Oct 2021 16:59:57 +0200	[thread overview]
Message-ID: <20211025165957.349a6580@collabora.com> (raw)
In-Reply-To: <20211025092752.2824678-3-sean@geanix.com>

Hello Sean,

On Mon, 25 Oct 2021 11:27:50 +0200
Sean Nyekjaer <sean@geanix.com> wrote:

The subject is misleading, how about 'mtd: mtdconcat: Don't use
mtd_{suspend,resume}()'

> Use MTD hooks to control suspend/resume of MTD devices.
> concat_{suspend,resume} will be called from mtd_{suspend,resume},
> which already have taken the suspend/resume lock.
> It's safe to proceed with calling MTD device hooks directly from here.

"
The MTD suspend logic will soon be adjusted to automatically wait for
device wake-up before issuing IOs. In order to do that a new read-write
lock will be added and taken in write-mode in the
mtd_{suspend,resume}() path. Since mtdconcat.c itself is an MTD device,
calling mtd_suspend/resume() on subdevices from the mtdconcat
->_{suspend,resume}() hook will lead to a nested lock, which lockdep
will complain about if we don't add a proper annotation. Let's keep
things simple and replace those mtd_{suspend,resume}(subdev) calls by
subdev->_{suspend,resume}() ones to avoid this situation.
"

> 
> Fixes: 013e6292aaf5 ("mtd: rawnand: Simplify the locking")

Again, this commit doesn't fix anything.

> Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
> Signed-off-by: Sean Nyekjaer <sean@geanix.com>
> ---
>  drivers/mtd/mtdconcat.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
> index f685a581df48..37532f529820 100644
> --- a/drivers/mtd/mtdconcat.c
> +++ b/drivers/mtd/mtdconcat.c
> @@ -566,9 +566,15 @@ static int concat_suspend(struct mtd_info *mtd)
>  
>  	for (i = 0; i < concat->num_subdev; i++) {
>  		struct mtd_info *subdev = concat->subdev[i];
> -		if ((rc = mtd_suspend(subdev)) < 0)
> +		/*
> +		 * Call MTD hook directly from here,
> +		 * mtd_suspend() have the suspend/resume lock.

		/*
		 * Call the MTD hook directly to avoid a nested lock
		 * on ->suspend_lock.
		 */

> +		 */
> +		rc = subdev->_suspend ? subdev->_suspend(subdev) : 0;
> +		if (rc < 0)
>  			return rc;
>  	}
> +
>  	return rc;
>  }
>  
> @@ -579,7 +585,12 @@ static void concat_resume(struct mtd_info *mtd)
>  
>  	for (i = 0; i < concat->num_subdev; i++) {
>  		struct mtd_info *subdev = concat->subdev[i];
> -		mtd_resume(subdev);
> +		/*
> +		 * Call MTD hook directly from here,
> +		 * mtd_resume() have the suspend/resume lock.
> +		 */

Ditto.

> +		if (subdev->_resume)
> +			subdev->_resume(subdev);
>  	}
>  }
>  


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

WARNING: multiple messages have this Message-ID (diff)
From: Boris Brezillon <boris.brezillon@collabora.com>
To: Sean Nyekjaer <sean@geanix.com>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Boris Brezillon <bbrezillon@kernel.org>,
	linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/4] mtd: mtdconcat: add suspend lock handling
Date: Mon, 25 Oct 2021 16:59:57 +0200	[thread overview]
Message-ID: <20211025165957.349a6580@collabora.com> (raw)
In-Reply-To: <20211025092752.2824678-3-sean@geanix.com>

Hello Sean,

On Mon, 25 Oct 2021 11:27:50 +0200
Sean Nyekjaer <sean@geanix.com> wrote:

The subject is misleading, how about 'mtd: mtdconcat: Don't use
mtd_{suspend,resume}()'

> Use MTD hooks to control suspend/resume of MTD devices.
> concat_{suspend,resume} will be called from mtd_{suspend,resume},
> which already have taken the suspend/resume lock.
> It's safe to proceed with calling MTD device hooks directly from here.

"
The MTD suspend logic will soon be adjusted to automatically wait for
device wake-up before issuing IOs. In order to do that a new read-write
lock will be added and taken in write-mode in the
mtd_{suspend,resume}() path. Since mtdconcat.c itself is an MTD device,
calling mtd_suspend/resume() on subdevices from the mtdconcat
->_{suspend,resume}() hook will lead to a nested lock, which lockdep
will complain about if we don't add a proper annotation. Let's keep
things simple and replace those mtd_{suspend,resume}(subdev) calls by
subdev->_{suspend,resume}() ones to avoid this situation.
"

> 
> Fixes: 013e6292aaf5 ("mtd: rawnand: Simplify the locking")

Again, this commit doesn't fix anything.

> Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
> Signed-off-by: Sean Nyekjaer <sean@geanix.com>
> ---
>  drivers/mtd/mtdconcat.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
> index f685a581df48..37532f529820 100644
> --- a/drivers/mtd/mtdconcat.c
> +++ b/drivers/mtd/mtdconcat.c
> @@ -566,9 +566,15 @@ static int concat_suspend(struct mtd_info *mtd)
>  
>  	for (i = 0; i < concat->num_subdev; i++) {
>  		struct mtd_info *subdev = concat->subdev[i];
> -		if ((rc = mtd_suspend(subdev)) < 0)
> +		/*
> +		 * Call MTD hook directly from here,
> +		 * mtd_suspend() have the suspend/resume lock.

		/*
		 * Call the MTD hook directly to avoid a nested lock
		 * on ->suspend_lock.
		 */

> +		 */
> +		rc = subdev->_suspend ? subdev->_suspend(subdev) : 0;
> +		if (rc < 0)
>  			return rc;
>  	}
> +
>  	return rc;
>  }
>  
> @@ -579,7 +585,12 @@ static void concat_resume(struct mtd_info *mtd)
>  
>  	for (i = 0; i < concat->num_subdev; i++) {
>  		struct mtd_info *subdev = concat->subdev[i];
> -		mtd_resume(subdev);
> +		/*
> +		 * Call MTD hook directly from here,
> +		 * mtd_resume() have the suspend/resume lock.
> +		 */

Ditto.

> +		if (subdev->_resume)
> +			subdev->_resume(subdev);
>  	}
>  }
>  


  reply	other threads:[~2021-10-25 15:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-25  9:27 [PATCH v3 0/4] mtd: core: protect access to mtd devices while in suspend Sean Nyekjaer
2021-10-25  9:27 ` Sean Nyekjaer
2021-10-25  9:27 ` [PATCH v3 1/4] mtd: rawnand: nand_bbt: hide suspend/resume hooks while scanning bbt Sean Nyekjaer
2021-10-25  9:27   ` Sean Nyekjaer
2021-10-25  9:27 ` [PATCH v3 2/4] mtd: mtdconcat: add suspend lock handling Sean Nyekjaer
2021-10-25  9:27   ` Sean Nyekjaer
2021-10-25 14:59   ` Boris Brezillon [this message]
2021-10-25 14:59     ` Boris Brezillon
2021-10-25  9:27 ` [PATCH v3 3/4] mtd: core: protect access to MTD devices while in suspend Sean Nyekjaer
2021-10-25  9:27   ` Sean Nyekjaer
2021-10-25  9:27 ` [PATCH v3 4/4] mtd: rawnand: remove suspended check Sean Nyekjaer
2021-10-25  9:27   ` Sean Nyekjaer

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=20211025165957.349a6580@collabora.com \
    --to=boris.brezillon@collabora.com \
    --cc=bbrezillon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=sean@geanix.com \
    --cc=vigneshr@ti.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.