Skip to contentSkip to conversation

MTD: make dataflash write-verify be optional

PATCH In review David Brownell 3 participants 3 messages Aug 7, 2008 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MTD: make dataflash write-verify be optional

From: David Brownell <[email protected]>

This adds a WRITE_VERIFY Kconfig option to the DataFlash driver, closely mirroring the similar NAND and ONENAND options, giving an option to disable some code that's currently always enabled.

Removing this step probably saves a millisecond or so per page when writing data, which will add up quickly since these pages are small (the largest is 1 KByte). It doesn't seem to add a lot in terms of reliability, and wouldn't detect errors which crop up when transferring data to the on-chip SRAM buffer.

---
 drivers/mtd/devices/Kconfig         |   10 ++++++++++
 drivers/mtd/devices/mtd_dataflash.c |    8 +++-----
 2 files changed, 13 insertions(+), 5 deletions(-)
drivers/mtd/devices/Kconfig +10 -0
@@ -59,6 +59,16 @@ config MTD_DATAFLASH
 	  Sometimes DataFlash chips are packaged inside MMC-format
 	  cards; at this writing, the MMC stack won't handle those.
 
+config MTD_DATAFLASH_WRITE_VERIFY
+	bool "Verify DataFlash page writes"
+	depends on MTD_DATAFLASH
+	help
+	  This adds an extra check when data is written to the flash.
+	  It may help if you are verifying chip setup (timings etc) on
+	  your board.  There is a rare possibility that even though the
+	  device thinks the write was successful, a bit could have been
+	  flipped accidentally due to device wear or something else.
+
 config MTD_DATAFLASH_OTP
 	bool "DataFlash OTP support (Security Register)"
 	depends on MTD_DATAFLASH
drivers/mtd/devices/mtd_dataflash.c +3 -5
@@ -30,12 +30,10 @@
  * doesn't (yet) use these for any kind of i/o overlap or prefetching.
  *
  * Sometimes DataFlash is packaged in MMC-format cards, although the
- * MMC stack can't use SPI (yet), or distinguish between MMC and DataFlash
+ * MMC stack can't (yet?) distinguish between MMC and DataFlash
  * protocols during enumeration.
  */
 
-#define CONFIG_DATAFLASH_WRITE_VERIFY
-
 /* reads can bypass the buffers */
 #define OP_READ_CONTINUOUS	0xE8
 #define OP_READ_PAGE		0xD2
@@ -403,7 +401,7 @@ static int dataflash_write(struct mtd_in
 		(void) dataflash_waitready(priv->spi);
 
 
-#ifdef	CONFIG_DATAFLASH_WRITE_VERIFY
+#ifdef CONFIG_MTD_DATAFLASH_VERIFY_WRITE
 
 		/* (3) Compare to Buffer1 */
 		addr = pageaddr << priv->page_offset;
@@ -432,7 +430,7 @@ static int dataflash_write(struct mtd_in
 		} else
 			status = 0;
 
-#endif	/* CONFIG_DATAFLASH_WRITE_VERIFY */
+#endif	/* CONFIG_MTD_DATAFLASH_VERIFY_WRITE */
 
 		remaining = remaining - writelen;
 		pageaddr++;
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · David Brownell

From: David Brownell <[email protected]>

This adds a WRITE_VERIFY Kconfig option to the DataFlash driver, closely mirroring the similar NAND and ONENAND options, giving an option to disable some code that's currently always enabled.

Quoted 7 lines

Removing this step probably saves a millisecond or so per page when writing data, which will add up quickly since these pages are small (the largest is 1 KByte). It doesn't seem to add a lot in terms of reliability, and wouldn't detect errors which crop up when transferring data to the on-chip SRAM buffer.

Sounds good to me. DataFlash speed is a bit of an issue, and if we eventually manage to boost the SPI transfer speed, this thing might turn out to be a bigger bottleneck than it currently is.

I suppose write verify might catch flash programming errors when the flash is worn out, so it makes sense to keep it optional for users that need to know early when this happens.

Acked-by on v1 1/1
#2 lore raw
In reply to David Brownell

hi,

Quoted 3 lines

It doesn't seem to add a
lot in terms of reliability, and wouldn't detect errors which crop up when transferring data to the on-chip SRAM buffer.

Yes, it was originally added for detecting bad/dead bits on the flash.

[I think some (obsolete) DataFlash revisions (C?) didn't have the compare functionality, though revision B did. Or atleast it wasn't defined in the rev C datasheets. It did return "success" on those chips though].