mtd: chips: AMD chip 0x2201 - write words not buffers
PATCH 1/1 mtd: chips: AMD chip 0x2201 - write words not buffers
CFI flash memory driver cmdset_0002 uses buffers for write operations. That does not work with AMD chip with id 0x2201 and we must resort to writing word sized chunks only.
This patch creates fixup mechanism that renders a chip to use word sized write operation and adds that as the last item in a fixup table, shadowing the entry that causes use of buffer writes.
Without the patch kernel logs will be flooded with entries like below:
MTD do_erase_oneblock(): ERASE 0x01fa0000
MTD do_write_buffer(): WRITE 0x01fa0000(0x00001985)
MTD do_erase_oneblock(): ERASE 0x01f80000
MTD do_write_buffer(): WRITE 0x01f80000(0x00001985)
MTD do_write_buffer_wait(): software timeout, address:0x01f8000a.
jffs2: Write clean marker to block at 0x01a60000 failed: -5 MTD do_erase_oneblock(): ERASE 0x01f60000
MTD do_write_buffer(): WRITE 0x01f60000(0x00001985)
MTD do_write_buffer_wait(): software timeout, address:0x01f6000a.
jffs2: Write clean marker to block at 0x01a40000 failed: -5
--- drivers/mtd/chips/cfi_cmdset_0002.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/mtd/chips/cfi_cmdset_0002.c +8 -0
@@ -279,6 +279,12 @@ static void fixup_use_write_buffers(struct mtd_info *mtd) }#endif /* !FORCE_WORD_WRITE */ +static void fixup_use_write_words (struct mtd_info *mtd) +{ +pr_debug ("Using word write method\n" ); + mtd->_write = cfi_amdstd_write_words; +} +/* Atmel chips don't use the same PRI format as AMD chips */ static void fixup_convert_atmel_pri (struct mtd_info *mtd) {
@@ -470,8 +476,10 @@ static struct cfi_fixup cfi_fixup_table[] = { #if !FORCE_WORD_WRITE { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers }, #endif + { CFI_MFR_AMD, 0x2201, fixup_use_write_words }, { 0, 0, NULL } }; + static struct cfi_fixup jedec_fixup_table[] = { { CFI_MFR_SST, SST49LF004B, fixup_use_fwh_lock }, { CFI_MFR_SST, SST49LF040B, fixup_use_fwh_lock },
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Vignesh Raghavendra
maintainerHi,
Quoted 4 lines · Mauri Sandberg
CFI flash memory driver
cmdset_0002uses buffers for write operations. That does not work with AMD chip with id0x2201and we must resort to writing word sized chunks only.
Which flash is this? Do you have datasheet for the same.
Please add above information to the commit message for future reference.
Quoted 17 lines
This patch creates fixup mechanism that renders a chip to use word sized write operation and adds that as the last item in a fixup table, shadowing the entry that causes use of buffer writes.
Without the patch kernel logs will be flooded with entries like below:
MTD
do_erase_oneblock(): ERASE0x01fa0000
MTDdo_write_buffer(): WRITE 0x01fa0000(0x00001985)
MTDdo_erase_oneblock(): ERASE0x01f80000
MTDdo_write_buffer(): WRITE 0x01f80000(0x00001985)
MTDdo_write_buffer_wait(): software timeout, address:0x01f8000a.
jffs2: Write clean marker to block at0x01a60000failed: -5 MTDdo_erase_oneblock(): ERASE0x01f60000
MTDdo_write_buffer(): WRITE 0x01f60000(0x00001985)
MTDdo_write_buffer_wait(): software timeout, address:0x01f6000a.
jffs2: Write clean marker to block at0x01a40000failed: -5
Quoted 2 lines
Signed-off-by Mauri Sandberg <[email protected]>---
1. Please explicitly CC maintainers for quicker response. Given the amount of traffic on Mailing list, it'll take quite a while for me to get to a patch that is not address directly to me.
Run ./scripts/get_maintainer.pl on the patch to get list of maintainers to be CC'd
2. $subject should start with appropriate prefix:
"mtd: cfi_cmdset_0002: ...."
Just run git log --oneline on the file being patched to know the convention.
If you don't CC the maintainers and use the appropriate prefixes, it will be a while until I get to such patches.
Quoted 8 lines
drivers/mtd/chips/cfi_cmdset_0002.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/mtd/chips/cfi_cmdset_0002.c +0
-0
drivers/mtd/chips/cfi_cmdset_0002.c static void fixup_use_write_buffers(struct mtd_info *mtd) · line 285
Quoted 7 lines
drivers/mtd/chips/cfi_cmdset_0002.c +4
-0@@ -279,6 +279,12 @@ static void fixup_use_write_buffers(struct mtd_info *mtd) }#endif /* !FORCE_WORD_WRITE */ +static void fixup_use_write_words (struct mtd_info *mtd) +{ +pr_debug ("Using word write method\n" ); + mtd->_write = cfi_amdstd_write_words;
Default is cfi_amdstd_write_words(). fixup_use_write_buffers() forces
this to cfi_amdstd_write_buffers() if cfi->cfiq->BufWriteTimeoutTyp is
non zero.
What does this field read in case of your flash? Should be 0 in case buffered write is not supported.
drivers/mtd/chips/cfi_cmdset_0002.c static struct cfi_fixup cfi_fixup_table[] = { · line 479
Quoted 10 lines
drivers/mtd/chips/cfi_cmdset_0002.c +3
-0+} +/* Atmel chips don't use the same PRI format as AMD chips */ static void fixup_convert_atmel_pri (struct mtd_info *mtd) {@@ -470,8 +476,10 @@ static struct cfi_fixup cfi_fixup_table[] = { #if !FORCE_WORD_WRITE { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers }, #endif + { CFI_MFR_AMD, 0x2201, fixup_use_write_words },
Should be worked around in fixup_use_write_buffers() instead. No point in overriding mtd->_write to cfi_amdstd_write_buffers() and then reverting it again.
drivers/mtd/chips/cfi_cmdset_0002.c static struct cfi_fixup cfi_fixup_table[] = { · line 482
Quoted 3 lines
drivers/mtd/chips/cfi_cmdset_0002.c +1
-0{ 0, 0, NULL } }; +
Please don't do white space fixes in the same patch adding code/feature/bug-fix
drivers/mtd/chips/cfi_cmdset_0002.c static struct cfi_fixup cfi_fixup_table[] = { · line 485
Quoted 4 lines
drivers/mtd/chips/cfi_cmdset_0002.c +0
-0static struct cfi_fixup jedec_fixup_table[] = { {CFI_MFR_SST ,SST49LF004B , fixup_use_fwh_lock }, {CFI_MFR_SST ,SST49LF040B , fixup_use_fwh_lock },
Regards
Vignesh
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Apologies for the etiquette mistakes. It's the first patch I am submitting. Answers to comments inline.
Quoted 9 lines
----------------------------------------
From: Vignesh Raghavendra <[email protected]>
Sent: Mon Mar 08 06:47:57 CET 2021
To: Mauri Sandberg <[email protected]>, <[email protected]>
Subject: Re: [PATCH] mtd: chips: AMD chip0x2201- write words not buffersHi,
Quoted 7 lines
Quoted 4 lines · Mauri Sandberg
CFI flash memory driver
cmdset_0002uses buffers for write operations. That does not work with AMD chip with id0x2201and we must resort to writing word sized chunks only.Which flash is this? Do you have datasheet for the same.
Appears to be a S29GL256N giving hits as Spansion and Cypress Semiconductor being the manufacturer. Datasheet is available too. Will make a note of that info.
Here's the link: https://www.cypress.com/file/219941/download
Quoted 60 lines
Please add above information to the commit message for future reference.
Quoted 17 lines
This patch creates fixup mechanism that renders a chip to use word sized write operation and adds that as the last item in a fixup table, shadowing the entry that causes use of buffer writes.
Without the patch kernel logs will be flooded with entries like below:
MTD
do_erase_oneblock(): ERASE0x01fa0000
MTDdo_write_buffer(): WRITE 0x01fa0000(0x00001985)
MTDdo_erase_oneblock(): ERASE0x01f80000
MTDdo_write_buffer(): WRITE 0x01f80000(0x00001985)
MTDdo_write_buffer_wait(): software timeout, address:0x01f8000a.
jffs2: Write clean marker to block at0x01a60000failed: -5 MTDdo_erase_oneblock(): ERASE0x01f60000
MTDdo_write_buffer(): WRITE 0x01f60000(0x00001985)
MTDdo_write_buffer_wait(): software timeout, address:0x01f6000a.
jffs2: Write clean marker to block at0x01a40000failed: -5Quoted 2 lines
Signed-off-by Mauri Sandberg <[email protected]>---
1. Please explicitly CC maintainers for quicker response. Given the amount of traffic on Mailing list, it'll take quite a while for me to get to a patch that is not address directly to me.
Run
./scripts/get_maintainer.plon the patch to get list of maintainers to be CC'd2. $subject should start with appropriate prefix:
"mtd: cfi_cmdset_0002: ...."Just run git log --oneline on the file being patched to know the convention.
If you don't CC the maintainers and use the appropriate prefixes, it will be a while until I get to such patches.
Quoted 8 lines
drivers/mtd/chips/cfi_cmdset_0002.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/mtd/chips/cfi_cmdset_0002.c +0
-0drivers/mtd/chips/cfi_cmdset_0002.c static void fixup_use_write_buffers(struct mtd_info *mtd) · line 285
Quoted 7 lines
drivers/mtd/chips/cfi_cmdset_0002.c +4
-0@@ -279,6 +279,12 @@ static void fixup_use_write_buffers(struct mtd_info *mtd) }#endif /* !FORCE_WORD_WRITE */ +static void fixup_use_write_words (struct mtd_info *mtd) +{ +pr_debug ("Using word write method\n" ); + mtd->_write = cfi_amdstd_write_words;Default is
cfi_amdstd_write_words().fixup_use_write_buffers()forces
this tocfi_amdstd_write_buffers()ifcfi->cfiq->BufWriteTimeoutTypis
non zero.
Quoted 2 lines
What does this field read in case of your flash? Should be 0 in case buffered write is not supported.
It gives me '6'. Datasheet does indicate that buffer writes are supported.
Quoted 24 lines
drivers/mtd/chips/cfi_cmdset_0002.c static struct cfi_fixup cfi_fixup_table[] = { · line 479
Quoted 11 lines
drivers/mtd/chips/cfi_cmdset_0002.c +3
-0+} +/* Atmel chips don't use the same PRI format as AMD chips */ static void fixup_convert_atmel_pri (struct mtd_info *mtd) {@@ -470,8 +476,10 @@ static struct cfi_fixup cfi_fixup_table[] = { #if !FORCE_WORD_WRITE { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers }, #endif + { CFI_MFR_AMD, 0x2201, fixup_use_write_words },Should be worked around in
fixup_use_write_buffers()instead. No point in overridingmtd->_writetocfi_amdstd_write_buffers()and then reverting it again.drivers/mtd/chips/cfi_cmdset_0002.c static struct cfi_fixup cfi_fixup_table[] = { · line 482
Quoted 3 lines
drivers/mtd/chips/cfi_cmdset_0002.c +1
-0{ 0, 0, NULL } }; +Please don't do white space fixes in the same patch adding code/feature/bug-fix
Quoted 7 lines
drivers/mtd/chips/cfi_cmdset_0002.c static struct cfi_fixup cfi_fixup_table[] = { · line 485
Quoted 4 lines
drivers/mtd/chips/cfi_cmdset_0002.c +0
-0static struct cfi_fixup jedec_fixup_table[] = { {CFI_MFR_SST ,SST49LF004B , fixup_use_fwh_lock }, {CFI_MFR_SST ,SST49LF040B , fixup_use_fwh_lock },Regards
Vignesh
--
Sent with https://mailfence.com
Secure and private email
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v2 1/1 mtd: cfi_cmdset_0002: AMD chip 0x2201 - write words
In reply to Mauri SandbergBuffer writes do not work with AMD chip 0x2201. The chip in question is a AMD/Spansion/Cypress Semiconductor S29GL256N and datasheet [1] talks about writing buffers being possible. While waiting for a neater solution resort to writing word-sized chunks only.
Without the patch kernel logs will be flooded with entries like below:
jffs2_scan_eraseblock(): End of filesystem marker found at 0x0 jffs2_build_filesystem(): unlocking the mtd device... done.jffs2_build_filesystem(): erasing all blocks after the end marker... MTD do_write_buffer_wait(): software timeout, address:0x01ec000a.
jffs2: Write clean marker to block at 0x01920000 failed: -5 MTD do_write_buffer_wait(): software timeout, address:0x01e2000a.
jffs2: Write clean marker to block at 0x01880000 failed: -5 MTD do_write_buffer_wait(): software timeout, address:0x01e0000a.
jffs2: Write clean marker to block at 0x01860000 failed: -5 MTD do_write_buffer_wait(): software timeout, address:0x01dc000a.
jffs2: Write clean marker to block at 0x01820000 failed: -5 MTD do_write_buffer_wait(): software timeout, address:0x01da000a.
jffs2: Write clean marker to block at 0x01800000 failed: -5
...
Tested on a Buffalo wzr-hp-g300nh running kernel 5.10.16.
[1] https://www.cypress.com/file/219941/download
or https://datasheetspdf.com/pdf-file/565708/SPANSION/S29GL256N/1
--- drivers/mtd/chips/cfi_cmdset_0002.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mtd/chips/cfi_cmdset_0002.c +4 -0
@@ -272,6 +272,10 @@ static void fixup_use_write_buffers(struct mtd_info *mtd) {struct map_info *map = mtd->priv;struct cfi_private *cfi = map->fldrv_priv; + +if ((cfi->mfr ==CFI_MFR_AMD ) && (cfi->id ==0x2201 )) +return ; +if (cfi->cfiq->BufWriteTimeoutTyp) {pr_debug ("Using buffer write method\n" ); mtd->_write = cfi_amdstd_write_buffers;
base-commit: 5de15b610f785f0e188fefb707f0b19de156968a
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v2] mtd: cfi_cmdset_0002: AMD chip 0x2201 - write words
Hi Mauri Sandberg,
Quoted 8 lines · Mauri Sandberg
Buffer writes do not work with AMD chip
0x2201. The chip in question is a AMD/Spansion/Cypress Semiconductor S29GL256N and datasheet [1] talks about writing buffers being possible. While waiting for a neater solution resort to writing word-sized chunks only.Without the patch kernel logs will be flooded with entries like below:
[...]
Reworded the $subject to:
mtd: cfi_cmdset_0002: Disable buffered writes for AMD chip 0x2201
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git cfi/next, thanks! [1/1] mtd: cfi_cmdset_0002: AMD chip 0x2201 - write words
https://git.kernel.org/mtd/c/7e44041136
--
Regards
Vignesh
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v2] mtd: cfi_cmdset_0002: AMD chip 0x2201 - write words
Quoted 7 lines
----------------------------------------
From: Vignesh Raghavendra <[email protected]>
Reworded the $subject to:mtd: cfi_cmdset_0002: Disable buffered writes for AMD chip 0x2201Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git cfi/next, thanks!
Thanks for the review!
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/