[PATCH][CFI] Wrong cache invalidation bug fix

massimo cirillo maxcir at gmail.com
Mon Dec 3 11:34:23 EST 2007


Hi,

We encountered the problem with cache invalidation in CFI driver. It
causes corruptions of data read from flash.

The problem is investigated. The original code performs cache
invalidation from "adr" to "adr + len" in do_write_buffer(). Since len
and adr could be updated in the code before invalidation - it causes
improper setting of cache invalidation regions.
The following patch fixes this problem. This patch has been verified
on our OMAP based platform.
Could you please acknowledge and commit this patch?

Thanks a lot.

Signed-off-by Massimo Cirillo <maxcir at gmail.com> and Giuseppe D'Eliseo
<giuseppedeliseo at gmail.com>

------

diff -aur a/drivers/mtd/chips/cfi_cmdset_0001.c
b/drivers/mtd/chips/cfi_cmdset_0001.c

--- a/drivers/mtd/chips/cfi_cmdset_0001.c	2007-11-20 20:15:02.000000000 +0300
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c	2007-11-29 19:42:08.000000000 +0300
@@ -1530,9 +1530,12 @@
 	int ret, wbufsize, word_gap, words;
 	const struct kvec *vec;
 	unsigned long vec_seek;
+	unsigned long initial_adr;
+	int initial_len=len;

 	wbufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize;
 	adr += chip->start;
+	initial_adr = adr;
 	cmd_adr = adr & ~(wbufsize-1);

 	/* Let's determine this according to the interleave only once */
@@ -1636,7 +1639,7 @@
 	chip->state = FL_WRITING;

 	ret = INVAL_CACHE_AND_WAIT(map, chip, cmd_adr,
-				   adr, len,
+				   initial_adr, initial_len,
 				   chip->buffer_write_time);
 	if (ret) {
 		map_write(map, CMD(0x70), cmd_adr);

------



More information about the linux-mtd mailing list