FAILED: patch "[PATCH] mtd: spi-nor: sst: Fix write enable before AAI sequence" failed to apply to 6.1-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.1-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.1.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-sizzling-activate-5c93@gregkh' --subject-prefix 'PATCH 6.1.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.
drivers/mtd/spi-nor/sst.c +13 -0
@@ -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. */
Sasha Levin
maintainerPATCH 1/2 mtd: spi-nor: sst: Factor out common write operation to `sst_nor_write_data()`
From: Csókás, Bence <[email protected]>
[ Upstream commit 18bcb4aa54eab75dce41e5c176a1c2bff94f0f79 ]
Writing to the Flash in sst_nor_write() is a 3-step process:
first an optional one-byte write to get 2-byte-aligned, then the bulk of the data is written out in vendor-specific 2-byte writes. Finally, if there's a byte left over, another one-byte write. This was implemented 3 times in the body of sst_nor_write(). To reduce code duplication, factor out these sub-steps to their own function.
Stable-dep-of: a0f64241d356 ("mtd: spi-nor: sst: Fix write enable before AAI sequence")
--- drivers/mtd/spi-nor/sst.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-)
drivers/mtd/spi-nor/sst.c +19 -20
@@ -117,6 +117,21 @@ static const struct flash_info sst_nor_parts[] = { .fixups = &sst26vf_nor_fixups }, }; +static int sst_nor_write_data (struct spi_nor *nor,loff_t to,size_t len, +const u_char *buf) +{ +u8 op = (len ==1 ) ?SPINOR_OP_BP :SPINOR_OP_AAI_WP ; +int ret; + + nor->program_opcode = op; + ret =spi_nor_write_data (nor, to,1 , buf); +if (ret <0 ) +return ret; +WARN (ret != len,"While writing %zu byte written %i bytes\n" , len, ret); + +return spi_nor_wait_till_ready (nor); +} +static int sst_nor_write (struct mtd_info *mtd,loff_t to,size_t len,size_t *retlen,const u_char *buf) {
@@ -138,16 +153,10 @@ static int sst_nor_write(struct mtd_info *mtd, loff_t to, size_t len,/* Start write from odd address. */ if (to %2 ) { - nor->program_opcode =SPINOR_OP_BP ; -/* write one byte. */ - ret =spi_nor_write_data (nor, to,1 , buf); + ret =sst_nor_write_data (nor, to,1 , buf);if (ret <0 ) goto out; -WARN (ret !=1 ,"While writing 1 byte written %i bytes\n" , ret); - ret =spi_nor_wait_till_ready (nor); -if (ret) - goto out; to++; actual++;
@@ -155,16 +164,11 @@ static int sst_nor_write(struct mtd_info *mtd, loff_t to, size_t len,/* Write out most of the data here. */ for (; actual < len -1 ; actual +=2 ) { - nor->program_opcode =SPINOR_OP_AAI_WP ; -/* write two bytes. */ - ret =spi_nor_write_data (nor, to,2 , buf + actual); + ret =sst_nor_write_data (nor, to,2 , buf + actual);if (ret <0 ) goto out; -WARN (ret !=2 ,"While writing 2 bytes written %i bytes\n" , ret); - ret =spi_nor_wait_till_ready (nor); -if (ret) - goto out; + to +=2 ; nor->sst_write_second = true; }
@@ -184,14 +188,9 @@ static int sst_nor_write(struct mtd_info *mtd, loff_t to, size_t len,if (ret) goto out; - nor->program_opcode =SPINOR_OP_BP ; - ret =spi_nor_write_data (nor, to,1 , buf + actual); + ret =sst_nor_write_data (nor, to,1 , buf + actual);if (ret <0 ) goto out; -WARN (ret !=1 ,"While writing 1 byte written %i bytes\n" , ret); - ret =spi_nor_wait_till_ready (nor); -if (ret) - goto out; actual +=1 ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 mtd: spi-nor: sst: Fix write enable before AAI sequence
From: Sanjaikumar V S <[email protected]>
[ Upstream commit a0f64241d3566a49c0a9b33ba7ae458ae22003a9 ]
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.
--- drivers/mtd/spi-nor/sst.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/mtd/spi-nor/sst.c +13 -0
@@ -153,6 +153,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 )
@@ -160,6 +162,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. */
Signature · 1 line
2.53.0