Skip to contentSkip to conversation

FAILED: patch "[PATCH] mtd: spi-nor: sst: Fix write enable before AAI sequence" failed to apply to 6.6-stable tree

PATCH [email protected] 2 participants 3 messages May 4 – May 15

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x a0f64241d3566a49c0a9b33ba7ae458ae22003a9
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026050405-manly-surplus-9d27@gregkh' --subject-prefix 'PATCH 6.6.y' HEAD^..

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From a0f64241d3566a49c0a9b33ba7ae458ae22003a9 Mon Sep 17 00:00:00 2001
From: Sanjaikumar V S <[email protected]>
Date: Wed, 11 Mar 2026 10:30:56 +0000
Subject: [PATCH] mtd: spi-nor: sst: Fix write enable before AAI sequence

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 when more data needs to be written. Use a local boolean for clarity.

Fixes b199489d37b2 ("mtd: spi-nor: add the framework for SPI NOR")
drivers/mtd/spi-nor/sst.c +13 -0
index 175211fe6a5e..db02c14ba16f 100644
@@ -203,6 +203,8 @@ static int sst_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
 
 	/* Start write from odd address. */
 	if (to % 2) {
+		bool needs_write_enable = (len > 1);
+
 		/* write one byte. */
 		ret = sst_nor_write_data(nor, to, 1, buf);
 		if (ret < 0)
@@ -210,6 +212,17 @@ static int sst_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
 
 		to++;
 		actual++;
+
+		/*
+		 * Byte program clears the write enable latch. If more
+		 * data needs to be written using the AAI sequence,
+		 * re-enable writes.
+		 */
+		if (needs_write_enable) {
+			ret = spi_nor_write_enable(nor);
+			if (ret)
+				goto out;
+		}
 	}
 
 	/* Write out most of the data here. */
#1 lore raw

Hello,

Quoted 71 lines · On 5/4/26 10:38, [email protected] wrote:

The patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x a0f64241d3566a49c0a9b33ba7ae458ae22003a9
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026050405-manly-surplus-9d27@gregkh' --subject-prefix 'PATCH 6.6.y' HEAD^..

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From a0f64241d3566a49c0a9b33ba7ae458ae22003a9 Mon Sep 17 00:00:00 2001
From: Sanjaikumar V S <[email protected]>
Date: Wed, 11 Mar 2026 10:30:56 +0000
Subject: [PATCH] mtd: spi-nor: sst: Fix write enable before AAI sequence

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 when more data needs to be written. Use a local boolean for clarity.

Fixes b199489d37b2 ("mtd: spi-nor: add the framework for SPI NOR")
drivers/mtd/spi-nor/sst.c +6 -0
index 175211fe6a5e..db02c14ba16f 100644
@@ -203,6 +203,8 @@ static int sst_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
 
  	/* Start write from odd address. */
  	if (to % 2) {
+		bool needs_write_enable = (len > 1);
+
  		/* write one byte. */
  		ret = sst_nor_write_data(nor, to, 1, buf);
  		if (ret < 0)
@@ -210,6 +212,17 @@ static int sst_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
 
  		to++;
  		actual++;
+
+		/*
+		 * Byte program clears the write enable latch. If more
+		 * data needs to be written using the AAI sequence,

drivers/mtd/spi-nor/sst.c static int sst_nor_write(struct mtd_info *mtd, loff_t to, size_t len, · line 228

Quoted 10 lines
drivers/mtd/spi-nor/sst.c +7 -0
+		 * re-enable writes.
+		 */
+		if (needs_write_enable) {
+			ret = spi_nor_write_enable(nor);
+			if (ret)
+				goto out;
+		}
  	}
 
  	/* Write out most of the data here. */

it doesn't apply because of changes made in
18bcb4aa54eab75dce41e5c176a1c2bff94f0f79.

That commit was never backported and is not in any stable tree older than 6.12.y. So it needs to be applied first to 5.10.y, 5.15.y, 6.1.y and 6.6.y. It's a refactor commit that should not change behaviour at all.

If that's not possible for some reason the conflict resolution looks easy enough. I have something i can send out for review if needed.

Regards,
Hendrik

author maintainer
#2 lore raw
Quoted 85 lines · Hendrik Donner

Hello,

Quoted 68 lines · On 5/4/26 10:38, [email protected] wrote:

The patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x a0f64241d3566a49c0a9b33ba7ae458ae22003a9
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026050405-manly-surplus-9d27@gregkh' --subject-prefix 'PATCH 6.6.y' HEAD^..

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From a0f64241d3566a49c0a9b33ba7ae458ae22003a9 Mon Sep 17 00:00:00 2001
From: Sanjaikumar V S <[email protected]>
Date: Wed, 11 Mar 2026 10:30:56 +0000
Subject: [PATCH] mtd: spi-nor: sst: Fix write enable before AAI sequence

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 when more data needs to be written. Use a local boolean for clarity.

Fixes b199489d37b2 ("mtd: spi-nor: add the framework for SPI NOR")
drivers/mtd/spi-nor/sst.c +6 -0
index 175211fe6a5e..db02c14ba16f 100644
@@ -203,6 +203,8 @@ static int sst_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
  	/* Start write from odd address. */
  	if (to % 2) {
+		bool needs_write_enable = (len > 1);
+
  		/* write one byte. */
  		ret = sst_nor_write_data(nor, to, 1, buf);
  		if (ret < 0)
@@ -210,6 +212,17 @@ static int sst_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
  		to++;
  		actual++;
+
+		/*
+		 * Byte program clears the write enable latch. If more
+		 * data needs to be written using the AAI sequence,

drivers/mtd/spi-nor/sst.c static int sst_nor_write(struct mtd_info *mtd, loff_t to, size_t len, · line 227

Quoted 10 lines
drivers/mtd/spi-nor/sst.c +7 -0
+		 * re-enable writes.
+		 */
+		if (needs_write_enable) {
+			ret = spi_nor_write_enable(nor);
+			if (ret)
+				goto out;
+		}
  	}
  	/* Write out most of the data here. */
 

it doesn't apply because of changes made in
18bcb4aa54eab75dce41e5c176a1c2bff94f0f79.

Quoted 3 lines

That commit was never backported and is not in any stable tree older than 6.12.y. So it needs to be applied first to 5.10.y, 5.15.y, 6.1.y and 6.6.y. It's a refactor commit that should not change behaviour at all.

The refactor commit worked for 6.1.y and 6.6.y, but not the others.

thanks,

greg k-h