Re: [PATCH v4 2/2] mtd: spi-nor: core: Fix AAI mode when dirmap is not available
From: Hendrik Donner
Date: Mon Mar 16 2026 - 09:48:44 EST
Hello,
On 3/11/26 11:30, Sanjaikumar V S wrote:
From: Sanjaikumar V S <sanjaikumar.vs@xxxxxxxxxxxxx>
When the SPI controller lacks direct mapping support, the fallback path
in spi_nor_spimem_write_data() uses nor->write_proto based operation
template. However, this template uses the standard page program opcode
set during probe, not the AAI opcode required for SST flash.
Add check for nodirmap flag to ensure the code falls through to
spi_nor_spimem_exec_op() path which builds the operation at runtime
with the correct program_opcode set by sst_nor_write_data().
Fixes: df5c21002cf4 ("mtd: spi-nor: use spi-mem dirmap API")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Sanjaikumar V S <sanjaikumar.vs@xxxxxxxxxxxxx>
---
drivers/mtd/spi-nor/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 8ffeb41c3e08..cb7f4d447156 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -281,7 +281,7 @@ static ssize_t spi_nor_spimem_write_data(struct spi_nor *nor, loff_t to,
if (spi_nor_spimem_bounce(nor, &op))
memcpy(nor->bouncebuf, buf, op.data.nbytes);
- if (nor->dirmap.wdesc) {
+ if (nor->dirmap.wdesc && !nor->dirmap.wdesc->nodirmap) {
nbytes = spi_mem_dirmap_write(nor->dirmap.wdesc, op.addr.val,
op.data.nbytes, op.data.buf.out);
} else {
found a board with
spi-nor spi0.0: sst25vf032b (4096 Kbytes)
for testing. Tests are on top of
94645aa41bf9e (mtd/spi-nor/next)
This patch fixes write errors, easily seen with flashcp, which tries to
verify writes:
flashcp: verification mismatch at 0x0
Tested-by: Hendrik Donner <hd@xxxxxxxxxxxxxxx>
Reviewed-by: Hendrik Donner <hd@xxxxxxxxxxxxxxx>
Regards,
Hendrik