3af641e62e282ddcbf5c3c86992e252533983ee3
[openwrt/openwrt.git] /
1 From 7e4404113686868858a34210c28ae122e967aa64 Mon Sep 17 00:00:00 2001
2 From: Mauri Sandberg <sandberg@mailfence.com>
3 Date: Tue, 9 Mar 2021 19:48:59 +0200
4 Subject: [PATCH] mtd: cfi_cmdset_0002: Disable buffered writes for AMD chip
5 0x2201
6
7 Buffer writes do not work with AMD chip 0x2201. The chip in question
8 is a AMD/Spansion/Cypress Semiconductor S29GL256N and datasheet [1]
9 talks about writing buffers being possible. While waiting for a neater
10 solution resort to writing word-sized chunks only.
11
12 Without the patch kernel logs will be flooded with entries like below:
13
14 jffs2_scan_eraseblock(): End of filesystem marker found at 0x0
15 jffs2_build_filesystem(): unlocking the mtd device...
16 done.
17 jffs2_build_filesystem(): erasing all blocks after the end marker...
18 MTD do_write_buffer_wait(): software timeout, address:0x01ec000a.
19 jffs2: Write clean marker to block at 0x01920000 failed: -5
20 MTD do_write_buffer_wait(): software timeout, address:0x01e2000a.
21 jffs2: Write clean marker to block at 0x01880000 failed: -5
22 MTD do_write_buffer_wait(): software timeout, address:0x01e0000a.
23 jffs2: Write clean marker to block at 0x01860000 failed: -5
24 MTD do_write_buffer_wait(): software timeout, address:0x01dc000a.
25 jffs2: Write clean marker to block at 0x01820000 failed: -5
26 MTD do_write_buffer_wait(): software timeout, address:0x01da000a.
27 jffs2: Write clean marker to block at 0x01800000 failed: -5
28 ...
29
30 Tested on a Buffalo wzr-hp-g300nh running kernel 5.10.16.
31
32 [1] https://www.cypress.com/file/219941/download
33 or https://datasheetspdf.com/pdf-file/565708/SPANSION/S29GL256N/1
34
35 Signed-off-by: Mauri Sandberg <sandberg@mailfence.com>
36 Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
37 Link: https://lore.kernel.org/r/20210309174859.362060-1-sandberg@mailfence.com
38 ---
39 drivers/mtd/chips/cfi_cmdset_0002.c | 4 ++++
40 1 file changed, 4 insertions(+)
41
42 --- a/drivers/mtd/chips/cfi_cmdset_0002.c
43 +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
44 @@ -272,6 +272,10 @@ static void fixup_use_write_buffers(stru
45 {
46 struct map_info *map = mtd->priv;
47 struct cfi_private *cfi = map->fldrv_priv;
48 +
49 + if (cfi->mfr == CFI_MFR_AMD && cfi->id == 0x2201)
50 + return;
51 +
52 if (cfi->cfiq->BufWriteTimeoutTyp) {
53 pr_debug("Using buffer write method\n");
54 mtd->_write = cfi_amdstd_write_buffers;