Re: [PATCH v2 1/2] mtd: spi-nor: sst: Fix write enable before AAI sequence

From: Michael Walle

Date: Mon Feb 23 2026 - 03:19:05 EST


Hi,

On Fri Feb 20, 2026 at 10:42 AM CET, Sanjaikumar V S wrote:
> From: Sanjaikumar V S <sanjaikumar.vs@xxxxxxxxxxxxx>
>
> When writing to SST flash starting at an odd address, a single byte is
> first programmed using the byte program (BP) command. After this
> operation completes, the flash hardware automatically clears the Write
> Enable Latch (WEL) bit.
>
> If an AAI (Auto Address Increment) word program sequence follows, it
> requires WEL to be set. Without re-enabling writes, the AAI sequence
> fails.
>
> Add spi_nor_write_enable() after the odd-address byte program, but only
> when an AAI sequence will follow (len > 2 bytes remaining).
>
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Sanjaikumar V S <sanjaikumar.vs@xxxxxxxxxxxxx>

Very strange. If that is correct, it actually never worked
correctly.

Fixes: b199489d37b2 ("mtd: spi-nor: add the framework for SPI NOR")

You've said, you didn't test this. Shouldn't it be pretty easy to
write to an odd offset? Also, from reading the code, it looks like
if write ends on an odd offset, it doesn't work either?

> ---
> drivers/mtd/spi-nor/sst.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/mtd/spi-nor/sst.c b/drivers/mtd/spi-nor/sst.c
> index 175211fe6a5e..fe714e6d0914 100644
> --- a/drivers/mtd/spi-nor/sst.c
> +++ b/drivers/mtd/spi-nor/sst.c
> @@ -210,6 +210,13 @@ static int sst_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
>
> to++;
> actual++;
> +
> + /* BP clears WEL, re-enable if AAI sequence follows */
> + if (actual < len - 1) {

For brevity, I'd drop the repeated condition and just do the
write_enable unconditionally.

-michael

> + ret = spi_nor_write_enable(nor);
> + if (ret)
> + goto out;
> + }
> }
>
> /* Write out most of the data here. */

Attachment: signature.asc
Description: PGP signature