From 7e4404113686868858a34210c28ae122e967aa64 Mon Sep 17 00:00:00 2001 From: Mauri Sandberg Date: Tue, 9 Mar 2021 19:48:59 +0200 Subject: mtd: cfi_cmdset_0002: Disable buffered writes for AMD chip 0x2201 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: 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 Signed-off-by: Mauri Sandberg Signed-off-by: Vignesh Raghavendra Link: https://lore.kernel.org/r/20210309174859.362060-1-sandberg@mailfence.com --- drivers/mtd/chips/cfi_cmdset_0002.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/mtd/chips') diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index a1f3e1031c3d..0bd8b5af28c6 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -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; -- cgit v1.2.3 From f3907773d60229afa8e6c0a3ee5085715192a9cb Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 25 Mar 2021 17:45:14 +0000 Subject: mtd: cfi_cmdset_0002: remove redundant assignment to variable timeo The variable timeo is being initialized with a value that is never read and it is being updated later with a new value. The initialization is redundant and can be removed. Signed-off-by: Colin Ian King Signed-off-by: Vignesh Raghavendra Link: https://lore.kernel.org/r/20210325174514.486272-1-colin.king@canonical.com Addresses-Coverity: ("Unused value") --- drivers/mtd/chips/cfi_cmdset_0002.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/mtd/chips') diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index 0bd8b5af28c6..627adc320913 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -1653,7 +1653,7 @@ static int __xipram do_write_oneword_once(struct map_info *map, unsigned long adr, map_word datum, int mode, struct cfi_private *cfi) { - unsigned long timeo = jiffies + HZ; + unsigned long timeo; /* * We use a 1ms + 1 jiffies generic timeout for writes (most devices * have a max write time of a few hundreds usec). However, we should -- cgit v1.2.3