mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: "Nuno Sá" <nuno.sa@analog.com>
Cc: linux-mtd@lists.infradead.org,  linux-kernel@vger.kernel.org,
	 Richard Weinberger <richard@nod.at>,
	 Vignesh Raghavendra <vigneshr@ti.com>
Subject: Re: [PATCH] mtd: spinand: winbond: Add support for W25N08LW
Date: Thu, 03 Sep 2026 12:12:15 +0200	[thread overview]
Message-ID: <87h5k64pa8.fsf@bootlin.com> (raw)
In-Reply-To: <20260831-mtd-nand-new-chip-support-v1-1-dca9f63ac0f9@analog.com> ("Nuno =?utf-8?Q?S=C3=A1=22's?= message of "Mon, 31 Aug 2026 16:38:10 +0100")

On 31/08/2026 at 16:38:10 +01, Nuno Sá <nuno.sa@analog.com> wrote:

> Add support for the W25N08LW, a 1.8V 8Gbit SPI-NAND made of two
> 4Gbit LUNs, with 4096-byte pages and 256 bytes of spare area.
>
> The chip reuses the KV ECC status helper, but needs its own OOB
> layout because the geometry of its spare area differs from the
> existing Winbond parts. Only half of it is visible while the
> internal ECC is enabled, so the ECC region is reported as
> inaccessible and just the free bytes are exposed.
>
> Assisted-by: Claude:Opus-5
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
>  drivers/mtd/nand/spi/winbond.c | 45 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 45 insertions(+)
>
> diff --git a/drivers/mtd/nand/spi/winbond.c b/drivers/mtd/nand/spi/winbond.c
> index 9b78c1e6cbc9..c2c4cc306f05 100644
> --- a/drivers/mtd/nand/spi/winbond.c
> +++ b/drivers/mtd/nand/spi/winbond.c
> @@ -345,6 +345,41 @@ static const struct mtd_ooblayout_ops w25n02kv_ooblayout = {
>  	.free = w25n02kv_ooblayout_free,
>  };
>  
> +static int w25n08lw_ooblayout_ecc(struct mtd_info *mtd, int section,
> +				  struct mtd_oob_region *region)
> +{
> +	/*
> +	 * With ecc enabled the parity bits are not accessible. So we can
> +	 * only see page + 128. Without ecc the full page + 256 is accessible.
> +	 * To make it simple just return the area as not accessible.
> +	 */
> +	return -ERANGE;
> +}
> +
> +static int w25n08lw_ooblayout_free(struct mtd_info *mtd, int section,
> +				   struct mtd_oob_region *region)
> +{
> +	if (section > 7)
> +		return -ERANGE;
> +
> +	region->offset = (16 * section);
> +	/* Note that we include User Data 2 which is not protected by ECC */

The more I think about these free bytes, the more I get convinced that
we should only expose ECC protected bytes. I honestly do not remember
any guarantee regarding these officially stated, the common case
(eg. UBI) there is no impact, but maybe it is best to only expose the
bytes that are actually protected, since the thresholds are getting
lower and lower (and chances to get bitflips there increase with the
optimizations of the technology).

Do you mind only exposing User Data 1?

Thanks,
Miquèl

  reply	other threads:[~2026-09-03 10:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 15:38 Nuno Sá
2026-09-03 10:12 ` Miquel Raynal [this message]
2026-09-03 12:40   ` Nuno Sá

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=87h5k64pa8.fsf@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=nuno.sa@analog.com \
    --cc=richard@nod.at \
    --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

all inboxes | Powered by JetHome®