From: sashiko-bot@kernel.org
To: "Miquel Raynal" <miquel.raynal@bootlin.com>,
"Pratyush Yadav" <pratyush@kernel.org>,
"Michael Walle" <mwalle@kernel.org>,
"Takahiro Kuwano" <takahiro.kuwano@infineon.com>,
"Richard Weinberger" <richard@nod.at>,
"Vignesh Raghavendra" <vigneshr@ti.com>
Cc: "Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
"Alvin Zhou" <alvinzhou@mxic.com.tw>,
"Cheng Ming Lin" <chengminglin@mxic.com.tw>,
linux-mtd@lists.infradead.org
Subject: Re: [PATCH 1/4] mtd: spi-nor: macronix: Clear the default RDCR opcode
Date: Wed, 25 Nov 2026 18:17:28 +0000 [thread overview]
Message-ID: <sashiko-outbox-233952@kernel.org> (raw)
In-Reply-To: <20261125-macronix-upstreaming-spi-nor-cleanup-v1-1-0d1ab783fd8b@bootlin.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] mtd: spi-nor: macronix: missing write_sr1 setup in
macronix_nor_default_init()
- [Medium] mtd: spi-nor: macronix: read_sr2 cleared before
spi_nor_parse_bfpt() reset
- [Low] mtd: spi-nor: macronix: missing Fixes trailer for commit
63489002d397
--
commit 5d3e4568e97ca20a41fbc446cff7e7e89070cad1
Author: Miquel Raynal <miquel.raynal@bootlin.com>
> mtd: spi-nor: macronix: Clear the default RDCR opcode
>
> The core defaults opcodes.read_sr2 to the JEDEC RDCR opcode (0x35).
> Macronix flashes do not use 0x35 to access their configuration
> register; they read it with 0x15, and some parts have no configuration
> register at all.
>
> Clear the opcode in the manufacturer default_init, which runs after the
> core default and before the SFDP parsing. Parts that do support the
> vendor opcode can then opt in from their own fixup.
>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
[Severity: Low]
Since this fixes the default SPINOR_OP_RDCR assignment for Macronix flashes,
should it include a Fixes: tag?
Fixes: 63489002d397 ("mtd: spi-nor: Refactor Read Status/Write Status support")
> diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c
> index b3fdb4b2fa1ca..2c6f507a2dde7 100644
> --- a/drivers/mtd/spi-nor/macronix.c
> +++ b/drivers/mtd/spi-nor/macronix.c
> @@ -333,6 +333,13 @@ static void macronix_nor_default_init(struct spi_nor *nor)
> {
> nor->params->qe_mask[0] = BIT(6);
> nor->params->qe_mask[1] = 0;
> +
> + /*
> + * The JEDEC RDCR opcode (0x35) is not valid for Macronix: some parts
> + * have no CR at all, others use 0x15. Clear the core default. Parts
> + * that do support the vendor opcode can opt-in from their own fixup.
> + */
> + nor->params->opcodes.read_sr2 = 0;
> }
>
> static int macronix_nor_late_init(struct spi_nor *nor)
[Severity: High]
Should macronix_nor_default_init() also set opcodes.write_sr1 = SPINOR_OP_WRSR
and clear opcodes.write_sr1_and_sr2 = 0, matching BFPT_DWORD15_QER_SR1_BIT6 in
spi_nor_parse_bfpt()?
spi_nor_init_default_params() initializes opcodes.write_sr1_and_sr2 to
SPINOR_OP_WRSR and leaves opcodes.write_sr1 as 0. On Macronix flashes without
SFDP (such as mx25l12805d) or with a 9-DWORD JESD216 v1.0 BFPT (such as
mx25l25635e), spi_nor_parse_bfpt() does not run the QER switch. When
spi_nor_generic_quad_enable() or software lock/unlock runs with read_sr2
cleared to 0, spi_nor_read_sr1_and_sr2() leaves sr[1] = 0 and
spi_nor_write_sr1_and_sr2() issues a 2-byte WRSR (0x01) command instead of a
1-byte SR1 write, either sending an invalid second byte to flashes without a
Configuration Register or overwriting the Configuration Register with 0x00.
[Severity: Medium]
Does clearing opcodes.read_sr2 in macronix_nor_default_init() get overwritten
by spi_nor_parse_bfpt() on flashes with a >9-DWORD BFPT table and
BFPT_DWORD15_QER_NONE?
macronix_nor_default_init() runs before SFDP parsing, and spi_nor_parse_bfpt()
unconditionally resets params->opcodes.read_sr2 = SPINOR_OP_RDCR before
switching on the QER field:
drivers/mtd/spi-nor/sfdp.c:spi_nor_parse_bfpt() {
...
params->opcodes.read_sr1 = SPINOR_OP_RDSR;
params->opcodes.read_sr2 = SPINOR_OP_RDCR;
params->opcodes.write_sr1 = SPINOR_OP_WRSR;
params->opcodes.write_sr1_and_sr2 = SPINOR_OP_WRSR;
params->qe_mask[0] = 0;
params->qe_mask[1] = 0;
/* Quad Enable Requirements. */
switch (bfpt.dwords[SFDP_DWORD(15)] & BFPT_DWORD15_QER_MASK) {
case BFPT_DWORD15_QER_NONE:
break;
...
}
Because BFPT_DWORD15_QER_NONE leaves opcodes.read_sr2 untouched, any Macronix
flash with >9 BFPT DWORDs and QER_NONE gets 0x35 restored and will still issue
RDCR during spi_nor_init(). A later patch in the series, commit "mtd:
spi-nor: macronix: Clear the RDCR opcode on MX25L3255E", works around this in
late_init for MX25L3255E, but other QER_NONE Macronix parts with >9 BFPT
DWORDs (such as octal-only flashes like MX25UW51245G) remain with read_sr2 set
to 0x35.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-macronix-upstreaming-spi-nor-cleanup-v1-0-0d1ab783fd8b@bootlin.com?part=1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2026-11-25 18:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 18:01 [PATCH 0/4] mtd: spi-nor: macronix: Improve general support Miquel Raynal
2026-11-25 18:01 ` [PATCH 1/4] mtd: spi-nor: macronix: Clear the default RDCR opcode Miquel Raynal
2026-11-25 18:17 ` sashiko-bot [this message]
2026-11-25 18:01 ` [PATCH 2/4] mtd: spi-nor: macronix: Clear the RDCR opcode on MX25L3255E Miquel Raynal
2026-11-25 18:22 ` sashiko-bot
2026-11-25 18:01 ` [PATCH 3/4] mtd: spi-nor: macronix: Enable RDCR for the parts that support it Miquel Raynal
2026-11-25 18:01 ` [PATCH 4/4] mtd: spi-nor: macronix: Describe locking support for MX25L51245G Miquel Raynal
2026-11-25 18:25 ` sashiko-bot
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=sashiko-outbox-233952@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alvinzhou@mxic.com.tw \
--cc=chengminglin@mxic.com.tw \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=mwalle@kernel.org \
--cc=pratyush@kernel.org \
--cc=richard@nod.at \
--cc=sashiko-reviews@lists.linux.dev \
--cc=takahiro.kuwano@infineon.com \
--cc=thomas.petazzoni@bootlin.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