The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: James Hilliard <james.hilliard1@gmail.com>
Cc: Richard Weinberger <richard@nod.at>,
	 Vignesh Raghavendra <vigneshr@ti.com>,
	 Arseniy Krasnov <AVKrasnov@sberdevices.ru>,
	 Boris Brezillon <bbrezillon@kernel.org>,
	 Kyle Roeschley <kyle.roeschley@ni.com>,
	 linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
	 stable@vger.kernel.org
Subject: Re: [PATCH v2 1/2] mtd: rawnand: macronix: serialize OTP access with NAND operations
Date: Tue, 24 Nov 2026 15:55:09 +0100	[thread overview]
Message-ID: <87a4mys2ia.fsf@bootlin.com> (raw)
In-Reply-To: <20261122-submit-rawnand-operation-locking-v1-v2-1-030bc867f0c7@gmail.com> (James Hilliard's message of "Sun, 22 Nov 2026 02:25:20 -0700")


> OTP I/O can also run while the chip is suspended.

Really? Where does that come from?

[...]

> --- a/drivers/mtd/nand/raw/nand_base.c
> +++ b/drivers/mtd/nand/raw/nand_base.c
> @@ -207,7 +207,7 @@ EXPORT_SYMBOL_GPL(nand_deselect_target);
>   *
>   * Release chip lock and wake up anyone waiting on the device.
>   */
> -static void nand_release_device(struct nand_chip *chip)
> +void nand_release_device(struct nand_chip *chip)

You export a core helper...

>  {
>  	/* Release the controller and the chip */
>  	mutex_unlock(&chip->controller->lock);
> @@ -336,7 +336,7 @@ static int nand_isbad_bbm(struct nand_chip *chip, loff_t ofs)
>   *
>   * Lock the device and its controller for exclusive access
>   */
> -static void nand_get_device(struct nand_chip *chip)
> +void nand_get_device(struct nand_chip *chip)
>  {
>  	/* Wait until the device is resumed. */
>  	while (1) {
> diff --git a/drivers/mtd/nand/raw/nand_macronix.c b/drivers/mtd/nand/raw/nand_macronix.c
> index 16847f28b19d..d7f5a9e7c240 100644
> --- a/drivers/mtd/nand/raw/nand_macronix.c
> +++ b/drivers/mtd/nand/raw/nand_macronix.c
> @@ -380,6 +380,7 @@ static int __macronix_30lfxg18ac_rw_otp(struct mtd_info *mtd,
>  	int ret, cleanup_ret;
>  
>  	nand = mtd_to_nand(mtd);
> +	nand_get_device(nand);

...and you use it across the entire OTP operation...

>  	nand_select_target(nand, 0);
>  
>  	ret = macronix_30lfxg18ac_otp_enable(nand);
> @@ -426,6 +427,7 @@ static int __macronix_30lfxg18ac_rw_otp(struct mtd_info *mtd,
>  			write ? "write" : "read");
>  
>  	nand_deselect_target(nand);
> +	nand_release_device(nand);
>  
>  	return ret ? ret : cleanup_ret;
>  }

...and in the commit log you mention:

> Make the existing NAND serialization helpers available within the raw
> NAND core and hold them across the entire OTP transaction

Why are you doing the serialization in one vendor driver then? Aren't
all the vendors affected by the exact same issue? Why isn't taking the
lock once for all in the core a better idea?

Miquèl

  reply	other threads:[~2026-11-24 14:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22  9:25 [PATCH v2 0/2] mtd: rawnand: serialize OTP and BBT recovery operations James Hilliard
2026-11-22  9:25 ` [PATCH v2 1/2] mtd: rawnand: macronix: serialize OTP access with NAND operations James Hilliard
2026-11-24 14:55   ` Miquel Raynal [this message]
2026-11-22  9:25 ` [PATCH v2 2/2] mtd: rawnand: serialize bad-block marker writes during BBT recovery James Hilliard

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=87a4mys2ia.fsf@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --cc=AVKrasnov@sberdevices.ru \
    --cc=bbrezillon@kernel.org \
    --cc=james.hilliard1@gmail.com \
    --cc=kyle.roeschley@ni.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=stable@vger.kernel.org \
    --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