Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: spi-nor: Ignore octal PP bits on < JESD216F
@ 2026-12-03 11:15 Paul Cercueil
  2026-12-03 11:42 ` sashiko-bot
  2026-12-03 11:43 ` Miquel Raynal
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Cercueil @ 2026-12-03 11:15 UTC (permalink / raw)
  To: Pratyush Yadav, Michael Walle, Takahiro Kuwano, Miquel Raynal,
	Richard Weinberger, Vignesh Raghavendra
  Cc: Nuno Sá, linux-mtd, Thomas Petazzoni, Paul Cercueil

Octal page program support was added in JESD216F. Before that, the bits
were marked as reserved. Some chips like the Winbond W25Q256JW have some
of these bits set, which caused octal PP support to be incorrectly
detected.

Signed-off-by: Paul Cercueil <paul.cercueil@bootlin.com>
---

This replaces my other patch sent recently:
"[PATCH] mtd: spi-nor: winbond: Drop octal PP support for W25Q256JW"
---
 drivers/mtd/spi-nor/sfdp.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c
index 4d77354ee1b2..a7b3fdb8f24e 100644
--- a/drivers/mtd/spi-nor/sfdp.c
+++ b/drivers/mtd/spi-nor/sfdp.c
@@ -1065,12 +1065,15 @@ static int spi_nor_parse_smpt(struct spi_nor *nor,
 /**
  * spi_nor_parse_4bait() - parse the 4-Byte Address Instruction Table
  * @nor:		pointer to a 'struct spi_nor'.
+ * @bfpt_header:	pointer to the 'struct sfdp_parameter_header' describing
+ *			the Basic Flash Parameter Table length and version.
  * @param_header:	pointer to the 'struct sfdp_parameter_header' describing
  *			the 4-Byte Address Instruction Table length and version.
  *
  * Return: 0 on success, -errno otherwise.
  */
 static int spi_nor_parse_4bait(struct spi_nor *nor,
+			       const struct sfdp_parameter_header *bfpt_header,
 			       const struct sfdp_parameter_header *param_header)
 {
 	static const struct sfdp_4bait reads[] = {
@@ -1162,6 +1165,12 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,
 			pp_hwcaps |= program->hwcaps;
 	}
 
+	/* The octal page program bits are reserved before JESD216F. */
+	if (bfpt_header->minor < SFDP_JESD216F_MINOR) {
+		discard_hwcaps |= SNOR_HWCAPS_PP_OCTAL;
+		pp_hwcaps &= ~SNOR_HWCAPS_PP_OCTAL;
+	}
+
 	/*
 	 * Compute the subset of Sector Erase commands for which the 4-byte
 	 * version is supported.
@@ -1683,7 +1692,7 @@ int spi_nor_parse_sfdp(struct spi_nor *nor)
 			break;
 
 		case SFDP_4BAIT_ID:
-			err = spi_nor_parse_4bait(nor, param_header);
+			err = spi_nor_parse_4bait(nor, bfpt_header, param_header);
 			break;
 
 		case SFDP_PROFILE1_ID:
-- 
2.47.3


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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd: spi-nor: Ignore octal PP bits on < JESD216F
  2026-12-03 11:15 [PATCH] mtd: spi-nor: Ignore octal PP bits on < JESD216F Paul Cercueil
@ 2026-12-03 11:42 ` sashiko-bot
  2026-12-03 11:43 ` Miquel Raynal
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-12-03 11:42 UTC (permalink / raw)
  To: Paul Cercueil, Pratyush Yadav, Michael Walle, Takahiro Kuwano,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
  Cc: Nuno Sá, linux-mtd, Thomas Petazzoni

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] mtd: spi-nor: spi_nor_parse_4bait() clears PP_8_8_8_DTR on
  pre-JESD216F
- [Medium] mtd: spi-nor: spi_nor_parse_4bait() checks bfpt_header->minor
  for JESD216F
- [Low] mtd: spi-nor: missing Fixes trailer for 4BAIT octal PP parsing
  commit
--

commit 74e692d12384eca7766679af6c7f7592d5e62317
Author: Paul Cercueil <paul.cercueil@bootlin.com>

> mtd: spi-nor: Ignore octal PP bits on < JESD216F
>
> Octal page program support was added in JESD216F. Before that, the bits
> were marked as reserved. Some chips like the Winbond W25Q256JW have some
> of these bits set, which caused octal PP support to be incorrectly
> detected.
>
> Signed-off-by: Paul Cercueil <paul.cercueil@bootlin.com>

[Severity: Low]
This fixes a regression introduced when 4BAIT started parsing the 1-1-8
and 1-8-8 page program bits.  Should this include:

  Fixes: 68d7115d77a8 ("mtd: spi-nor: sfdp: get the 1-1-8 and 1-8-8 page programs from 4BAIT")

> diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c
> index e0854b8f1d551..c3e6af66873a6 100644
> --- a/drivers/mtd/spi-nor/sfdp.c
> +++ b/drivers/mtd/spi-nor/sfdp.c

[ ... ]

> @@ -1162,6 +1165,12 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,
>  			pp_hwcaps |= program->hwcaps;
>  	}
>  
> +	/* The octal page program bits are reserved before JESD216F. */
> +	if (bfpt_header->minor < SFDP_JESD216F_MINOR) {

[Severity: Medium]
Should this check spi_nor_sfdp_get_header(nor)->minor instead of
bfpt_header->minor?

4BAIT is an independent optional parameter table.  On a JESD216F flash
that reports a JESD216F top-level SFDP header while keeping an earlier
BFPT revision, checking bfpt_header->minor will discard valid 4-byte
1-1-8 and 1-8-8 page program support.

nor->sfdp is already populated before optional tables are parsed, so
spi_nor_parse_4bait() can check spi_nor_sfdp_get_header(nor)->minor like
is_w25qxxrv() and is_w25qxxpw() in winbond.c without taking bfpt_header.

> +		discard_hwcaps |= SNOR_HWCAPS_PP_OCTAL;
> +		pp_hwcaps &= ~SNOR_HWCAPS_PP_OCTAL;
> +	}

[Severity: High]
Does adding SNOR_HWCAPS_PP_OCTAL to discard_hwcaps strip
SNOR_HWCAPS_PP_8_8_8_DTR on pre-JESD216F Octal DTR flashes?

SNOR_HWCAPS_PP_OCTAL includes PP_8_8_8 and PP_8_8_8_DTR in addition to
PP_1_1_8 and PP_1_8_8, whereas 4BAIT only handles PP_1_1_8 and PP_1_8_8
(already added to discard_hwcaps by the programs[] loop).

If xSPI Profile 1.0 precedes 4BAIT in SFDP, spi_nor_parse_profile1()
sets READ_8_8_8_DTR and PP_8_8_8_DTR, and 4BAIT then clears only
PP_8_8_8_DTR.  spi_nor_set_octal_dtr() then sees a read/write protocol
mismatch and skips entering 8D-8D-8D mode while reads still use 8D-8D-8D.

Dropping the discard_hwcaps assignment and clearing only
SNOR_HWCAPS_PP_1_1_8 | SNOR_HWCAPS_PP_1_8_8 from pp_hwcaps avoids
clearing PP_8_8_8 and PP_8_8_8_DTR.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203111545.55678-1-paul.cercueil@bootlin.com?part=1

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd: spi-nor: Ignore octal PP bits on < JESD216F
  2026-12-03 11:15 [PATCH] mtd: spi-nor: Ignore octal PP bits on < JESD216F Paul Cercueil
  2026-12-03 11:42 ` sashiko-bot
@ 2026-12-03 11:43 ` Miquel Raynal
  1 sibling, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2026-12-03 11:43 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Pratyush Yadav, Michael Walle, Takahiro Kuwano,
	Richard Weinberger, Vignesh Raghavendra, Nuno Sá, linux-mtd,
	Thomas Petazzoni

On 03/12/2026 at 12:15:45 +01, Paul Cercueil <paul.cercueil@bootlin.com> wrote:

> Octal page program support was added in JESD216F. Before that, the bits
> were marked as reserved. Some chips like the Winbond W25Q256JW have some
> of these bits set, which caused octal PP support to be incorrectly
> detected.
>
> Signed-off-by: Paul Cercueil <paul.cercueil@bootlin.com>
> ---

While I agree this is a much better patch than the previous one, could
we just skip octal PP setting if SFDP version is incorrect, rather than
going through the parsing and then dropping the bits?

If we aver add more parsing, it would also need to be cancelled with
this approach, which is error prone.

I don't know how easy that would be to do, but I believe it would be
preferable to just skip the parsing.

Miquèl

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-03 11:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 11:15 [PATCH] mtd: spi-nor: Ignore octal PP bits on < JESD216F Paul Cercueil
2026-12-03 11:42 ` sashiko-bot
2026-12-03 11:43 ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox