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 v2 2/4] mtd: core: protect access to MTD devices while in suspend
Date: Wed, 20 Oct 2021 11:13:47 +0200 [thread overview]
Message-ID: <20211020111347.627159a2@collabora.com> (raw)
In-Reply-To: <20211020084534.2472305-3-sean@geanix.com>
On Wed, 20 Oct 2021 10:45:32 +0200
Sean Nyekjaer <sean@geanix.com> wrote:
> static ssize_t mtd_otp_size(struct mtd_info *mtd, bool is_user)
> @@ -1257,6 +1259,8 @@ int mtd_erase(struct mtd_info *mtd, sruct erase_info *instr)
>
> ledtrig_mtd_activity();
>
> + mtd_start_access(master);
> +
> if (mtd->flags & MTD_SLC_ON_MLC_EMULATION) {
> adjinstr.addr = (loff_t)mtd_div_by_eb(instr->addr, mtd) *
> master->erasesize;
> @@ -1278,6 +1282,8 @@ int mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
> }
> }
>
> + mtd_end_access(master);
> +
The section covered in mtd_erase() is too broad. Put the start/end
calls around the ->_erase() call.
> return ret;
> }
> @@ -1576,7 +1604,6 @@ int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)
> ret_code = mtd_read_oob_std(mtd, from, ops);
>
> mtd_update_ecc_stats(mtd, master, &old_stats);
> -
Unrelated line removal. Please drop this change.
> /*
> * In cases where ops->datbuf != NULL, mtd->_read_oob() has semantics
> * similar to mtd->_read(), returning a non-negative integer
> @@ -1615,7 +1642,9 @@ int mtd_write_oob(struct mtd_info *mtd, loff_t to,
> if (mtd->flags & MTD_SLC_ON_MLC_EMULATION)
> return mtd_io_emulated_slc(mtd, to, false, ops);
>
> - return mtd_write_oob_std(mtd, to, ops);
> + ret = mtd_write_oob_std(mtd, to, ops);
> +
> + return ret;
Ditto, you can keep the 'return mtd_write_oob_std(mtd, to, ops);' here.
> }
> EXPORT_SYMBOL_GPL(mtd_write_oob);
> +static inline void mtd_start_access(struct mtd_info *master)
> +{
> + WARN_ON_ONCE(master != mtd_get_master(master));
> +
> + /*
> + * Don't take the suspend_lock on devices that don't
> + * implement the suspend hook. Otherwise, lockdep will
> + * complain about nested locks when trying to suspend MTD
> + * partitions or MTD devices created by gluebi which are
> + * backed by real devices.
> + */
> + if (!master->_suspend)
> + return;
> +
> + /*
> + * Wait until the device is resumed. Should we have a
> + * non-blocking mode here?
> + */
> + while (1) {
> + down_read(&master->master.suspend_lock);
> + if (!master->master.suspended)
> + return;
> +
> + up_read(&master->master.suspend_lock);
> + wait_event(master->master.resume_wq, master->master.suspended == 0);
Please keep the tests consistent:
wait_event(master->master.resume_wq, !master->master.suspended);
> + }
> +}
> +
next prev parent reply other threads:[~2021-10-20 9:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-20 8:45 [PATCH v2 0/4] mtd: core: protect access to mtd devices while in suspend Sean Nyekjaer
2021-10-20 8:45 ` [PATCH v3 1/4] mtd: rawnand: nand_bbt: hide suspend/resume hooks while scanning bbt Sean Nyekjaer
2021-10-20 8:53 ` Boris Brezillon
2021-10-20 9:01 ` Sean Nyekjaer
2021-10-20 9:03 ` Boris Brezillon
2021-10-20 9:12 ` Miquel Raynal
2021-10-20 8:45 ` [PATCH v2 2/4] mtd: core: protect access to MTD devices while in suspend Sean Nyekjaer
2021-10-20 9:13 ` Boris Brezillon [this message]
2021-10-20 8:45 ` [PATCH v2 3/4] mtd: rawnand: remove suspended check Sean Nyekjaer
2021-10-20 8:57 ` Boris Brezillon
2021-10-20 9:14 ` Sean Nyekjaer
2021-10-20 8:45 ` [PATCH v2 4/4] mtd: mtdconcat: add suspend lock handling Sean Nyekjaer
2021-10-20 8:55 ` 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=20211020111347.627159a2@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox