All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Nuno Sá" <nuno.sa@analog.com>
To: Miquel Raynal <miquel.raynal@bootlin.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, 3 Sep 2026 13:40:22 +0100	[thread overview]
Message-ID: <aplqm-84OXtDF4oV@nsa> (raw)
In-Reply-To: <87h5k64pa8.fsf@bootlin.com>

On Thu, Sep 03, 2026 at 12:12:15PM +0200, Miquel Raynal wrote:
> 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?

Not at all! Will re-spin with that in mind!

Thx!
- Nuno Sá

> 
> Thanks,
> Miquèl
> 
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

WARNING: multiple messages have this Message-ID (diff)
From: "Nuno Sá" <nuno.sa@analog.com>
To: Miquel Raynal <miquel.raynal@bootlin.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, 3 Sep 2026 13:40:22 +0100	[thread overview]
Message-ID: <aplqm-84OXtDF4oV@nsa> (raw)
In-Reply-To: <87h5k64pa8.fsf@bootlin.com>

On Thu, Sep 03, 2026 at 12:12:15PM +0200, Miquel Raynal wrote:
> 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?

Not at all! Will re-spin with that in mind!

Thx!
- Nuno Sá

> 
> Thanks,
> Miquèl
> 
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 15:38 [PATCH] mtd: spinand: winbond: Add support for W25N08LW Nuno Sá
2026-08-31 15:38 ` Nuno Sá
2026-09-03 10:12 ` Miquel Raynal
2026-09-03 10:12   ` Miquel Raynal
2026-09-03 12:40   ` Nuno Sá [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=aplqm-84OXtDF4oV@nsa \
    --to=nuno.sa@analog.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.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 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.