From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Sean Nyekjaer <sean@geanix.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 0/3] mtd: core: protect access to mtd devices while in suspend
Date: Fri, 15 Oct 2021 08:22:06 +0200 [thread overview]
Message-ID: <20211015082206.244a2316@xps13> (raw)
In-Reply-To: <20211011160546.707b737b@collabora.com>
Hi Sean,
boris.brezillon@collabora.com wrote on Mon, 11 Oct 2021 16:05:46 +0200:
> On Mon, 11 Oct 2021 13:52:50 +0200
> Sean Nyekjaer <sean@geanix.com> wrote:
>
> > Follow-up on discussion in https://lkml.org/lkml/2021/10/4/41
> >
> > Changes since from rfc v1/v2:
> > - added access protection for all device access hooks in mtd_info.
> > - added Suggested-by to [1/3] patch.
> > - removed refereces to commit ef347c0cfd61 ("mtd: rawnand: gpmi: Implement exec_op")
> > from commit msg as commit 013e6292aaf5 ("mtd: rawnand: Simplify the locking") is
> > to be blamed.
> > - tested on a kernel with LOCKDEP enabled.
> >
> > @Miquel: I havn't covered every ioctl, to me it looks like they havn't
> > direct device access.
Yes indeed it looks like they re-use most of the mtdcore.c functions,
so it should be fine.
> > One (small) issue still present. gpmi_nand.c uses the rwsem before it's
> > initialized. Seems cumbersome to have every mtd/nand driver to call
> > init_waitqueue_head() and init_rwsem(). Could we somehow move the call
> > to mtd_set_dev_defaults() before nand_create_bbt()?
>
> I have a nasty trick for that one, but I'm not sure Miquel will like it
> (actually, I don't like it either, but it's so simple compared to the
> other options we have that I'm tempted to go for this approach until
> someone has time to invest in a cleaner solution :-)):
>
> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> index 3d6c6e880520..a9ac2d528a4d 100644
> --- a/drivers/mtd/nand/raw/nand_base.c
> +++ b/drivers/mtd/nand/raw/nand_base.c
> @@ -6222,8 +6222,6 @@ static int nand_scan_tail(struct nand_chip *chip)
> mtd->_sync = nand_sync;
> mtd->_lock = nand_lock;
> mtd->_unlock = nand_unlock;
> - mtd->_suspend = nand_suspend;
> - mtd->_resume = nand_resume;
> mtd->_reboot = nand_shutdown;
> mtd->_block_isreserved = nand_block_isreserved;
> mtd->_block_isbad = nand_block_isbad;
> @@ -6269,6 +6267,13 @@ static int nand_scan_tail(struct nand_chip *chip)
> if (ret)
> goto err_free_secure_regions;
>
> + /*
> + * Populate the suspend/resume hooks after the BBT has been scanned to
> + * avoid using the suspend lock and resume waitqueue which are only
> + * initialized when mtd_device_register() is called.
> + */
> + mtd->_suspend = nand_suspend;
> + mtd->_resume = nand_resume;
> return 0;
I'm fine with this as long as it is documented for now.
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
WARNING: multiple messages have this Message-ID (diff)
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Sean Nyekjaer <sean@geanix.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 0/3] mtd: core: protect access to mtd devices while in suspend
Date: Fri, 15 Oct 2021 08:22:06 +0200 [thread overview]
Message-ID: <20211015082206.244a2316@xps13> (raw)
In-Reply-To: <20211011160546.707b737b@collabora.com>
Hi Sean,
boris.brezillon@collabora.com wrote on Mon, 11 Oct 2021 16:05:46 +0200:
> On Mon, 11 Oct 2021 13:52:50 +0200
> Sean Nyekjaer <sean@geanix.com> wrote:
>
> > Follow-up on discussion in https://lkml.org/lkml/2021/10/4/41
> >
> > Changes since from rfc v1/v2:
> > - added access protection for all device access hooks in mtd_info.
> > - added Suggested-by to [1/3] patch.
> > - removed refereces to commit ef347c0cfd61 ("mtd: rawnand: gpmi: Implement exec_op")
> > from commit msg as commit 013e6292aaf5 ("mtd: rawnand: Simplify the locking") is
> > to be blamed.
> > - tested on a kernel with LOCKDEP enabled.
> >
> > @Miquel: I havn't covered every ioctl, to me it looks like they havn't
> > direct device access.
Yes indeed it looks like they re-use most of the mtdcore.c functions,
so it should be fine.
> > One (small) issue still present. gpmi_nand.c uses the rwsem before it's
> > initialized. Seems cumbersome to have every mtd/nand driver to call
> > init_waitqueue_head() and init_rwsem(). Could we somehow move the call
> > to mtd_set_dev_defaults() before nand_create_bbt()?
>
> I have a nasty trick for that one, but I'm not sure Miquel will like it
> (actually, I don't like it either, but it's so simple compared to the
> other options we have that I'm tempted to go for this approach until
> someone has time to invest in a cleaner solution :-)):
>
> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> index 3d6c6e880520..a9ac2d528a4d 100644
> --- a/drivers/mtd/nand/raw/nand_base.c
> +++ b/drivers/mtd/nand/raw/nand_base.c
> @@ -6222,8 +6222,6 @@ static int nand_scan_tail(struct nand_chip *chip)
> mtd->_sync = nand_sync;
> mtd->_lock = nand_lock;
> mtd->_unlock = nand_unlock;
> - mtd->_suspend = nand_suspend;
> - mtd->_resume = nand_resume;
> mtd->_reboot = nand_shutdown;
> mtd->_block_isreserved = nand_block_isreserved;
> mtd->_block_isbad = nand_block_isbad;
> @@ -6269,6 +6267,13 @@ static int nand_scan_tail(struct nand_chip *chip)
> if (ret)
> goto err_free_secure_regions;
>
> + /*
> + * Populate the suspend/resume hooks after the BBT has been scanned to
> + * avoid using the suspend lock and resume waitqueue which are only
> + * initialized when mtd_device_register() is called.
> + */
> + mtd->_suspend = nand_suspend;
> + mtd->_resume = nand_resume;
> return 0;
I'm fine with this as long as it is documented for now.
Thanks,
Miquèl
next prev parent reply other threads:[~2021-10-15 6:23 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-11 11:52 [PATCH 0/3] mtd: core: protect access to mtd devices while in suspend Sean Nyekjaer
2021-10-11 11:52 ` Sean Nyekjaer
2021-10-11 11:52 ` [PATCH 1/3] mtd: core: protect access to MTD " Sean Nyekjaer
2021-10-11 11:52 ` Sean Nyekjaer
2021-10-11 13:37 ` Boris Brezillon
2021-10-11 13:37 ` Boris Brezillon
2021-10-14 6:50 ` [mtd] d3ff51cfa9: WARNING:at_kernel/locking/rwsem.c:#down_read kernel test robot
2021-10-14 6:50 ` kernel test robot
2021-10-14 6:50 ` kernel test robot
2021-10-15 6:55 ` [PATCH 1/3] mtd: core: protect access to MTD devices while in suspend Boris Brezillon
2021-10-15 6:55 ` Boris Brezillon
2021-10-11 11:52 ` [PATCH 2/3] mtd: rawnand: remove suspended check Sean Nyekjaer
2021-10-11 11:52 ` Sean Nyekjaer
2021-10-11 11:52 ` [PATCH 3/3] mtd: mtdconcat: add suspend lock handling Sean Nyekjaer
2021-10-11 11:52 ` Sean Nyekjaer
2021-10-11 13:15 ` Boris Brezillon
2021-10-11 13:15 ` Boris Brezillon
2021-10-11 13:27 ` Boris Brezillon
2021-10-11 13:27 ` Boris Brezillon
2021-10-11 13:35 ` Sean Nyekjaer
2021-10-11 13:35 ` Sean Nyekjaer
2021-10-11 13:49 ` Boris Brezillon
2021-10-11 13:49 ` Boris Brezillon
2021-10-11 13:58 ` Boris Brezillon
2021-10-11 13:58 ` Boris Brezillon
2021-10-11 14:05 ` [PATCH 0/3] mtd: core: protect access to mtd devices while in suspend Boris Brezillon
2021-10-11 14:05 ` Boris Brezillon
2021-10-15 6:22 ` Miquel Raynal [this message]
2021-10-15 6:22 ` Miquel Raynal
2021-10-19 18:08 ` Sean Nyekjaer
2021-10-19 18:08 ` Sean Nyekjaer
2021-10-20 6:52 ` Boris Brezillon
2021-10-20 6:52 ` Boris Brezillon
2021-10-20 7:00 ` Boris Brezillon
2021-10-20 7:00 ` Boris Brezillon
2021-10-20 7:12 ` Miquel Raynal
2021-10-20 7:12 ` Miquel Raynal
2021-10-20 7:23 ` Sean Nyekjaer
2021-10-20 7:23 ` Sean Nyekjaer
2021-10-20 7:47 ` Boris Brezillon
2021-10-20 7:47 ` Boris Brezillon
2021-10-20 7:12 ` Sean Nyekjaer
2021-10-20 7:12 ` Sean Nyekjaer
2021-10-20 7:23 ` Miquel Raynal
2021-10-20 7:23 ` Miquel Raynal
2021-10-20 7:30 ` Boris Brezillon
2021-10-20 7:30 ` Boris Brezillon
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=20211015082206.244a2316@xps13 \
--to=miquel.raynal@bootlin.com \
--cc=bbrezillon@kernel.org \
--cc=boris.brezillon@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--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.