Re: [PATCH v4 2/2] mtd: spi-nor: core: Fix AAI mode when dirmap is not available
From: Pratyush Yadav
Date: Mon Mar 30 2026 - 10:36:46 EST
On Wed, Mar 11 2026, 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.
But if the controller does support direct mapping, won't it end up using
the wrong opcode? Would it be a better idea to update the dirmap_info
with the right opcodes?
>
> 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 {
--
Regards,
Pratyush Yadav