Patchwork [v2,1/6] mtd: add writebufsize field to mtd_info struct

login
register
mail settings
Submitter Anatolij Gustschin
Date Dec. 16, 2010, 10:42 p.m.
Message ID <1292539339-25111-2-git-send-email-agust@denx.de>
Download mbox | patch
Permalink /patch/75812/
State New
Headers show

Comments

Anatolij Gustschin - Dec. 16, 2010, 10:42 p.m.
This field will be used to indicate the write buffer size
of the MTD device. UBI will set it's minimal I/O unit size
(min_io_size) to the indicated write buffer size. By this
change we intend to fix failed recovery of UBIFS partitions
we currently observe on NOR flash when mounting the partition
after unclean unmount.

Currently the min_io_size is set to mtd->writesize (which is 1
byte for NOR flash). But flash programming is often done from
prepared write buffer containing multiple bytes and is performed
in one programming operation which could be interrupted by a power
cut or a system reset causing corrupted (partially written) areas
in a flash sector. Knowing the size of potentially corrupted areas
UBIFS scanning and recovery algorithms are able to perform
successful recovery.

In case of NOR flash minimal I/O size must be equal to the
maximal size of the write buffer used by embedded flash
programming algorithm. In case of NAND flash mtd->writebufsize
should be equivalent to mtd->writesize.

The subsequent patches will add mtd->writebufsize initialization
where needed.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
 include/linux/mtd/mtd.h |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
Artem Bityutskiy - Dec. 19, 2010, 5:45 p.m.
On Thu, 2010-12-16 at 23:42 +0100, Anatolij Gustschin wrote:
> This field will be used to indicate the write buffer size
> of the MTD device. UBI will set it's minimal I/O unit size
> (min_io_size) to the indicated write buffer size. By this
> change we intend to fix failed recovery of UBIFS partitions
> we currently observe on NOR flash when mounting the partition
> after unclean unmount.
> 
> Currently the min_io_size is set to mtd->writesize (which is 1
> byte for NOR flash). But flash programming is often done from
> prepared write buffer containing multiple bytes and is performed
> in one programming operation which could be interrupted by a power
> cut or a system reset causing corrupted (partially written) areas
> in a flash sector. Knowing the size of potentially corrupted areas
> UBIFS scanning and recovery algorithms are able to perform
> successful recovery.
> 
> In case of NOR flash minimal I/O size must be equal to the
> maximal size of the write buffer used by embedded flash
> programming algorithm. In case of NAND flash mtd->writebufsize
> should be equivalent to mtd->writesize.
> 
> The subsequent patches will add mtd->writebufsize initialization
> where needed.
> 
> Signed-off-by: Anatolij Gustschin <agust@denx.de>

I've tweaked your commentary a bit and pushed to l2-mtd-2.6.git, please,
check.
Anatolij Gustschin - Dec. 20, 2010, 9:15 a.m.
On Sun, 19 Dec 2010 19:45:31 +0200
Artem Bityutskiy <dedekind1@gmail.com> wrote:

> I've tweaked your commentary a bit and pushed to l2-mtd-2.6.git, please,
> check.

It is ok. Thanks!

Anatolij

Patch

diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index fe8d77e..3c6db0c 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -144,6 +144,19 @@  struct mtd_info {
 	 */
 	uint32_t writesize;
 
+	/*
+	 * Size of the write buffer used by the MTD.
+	 * MTD devices having a write buffer can write multiple writesize
+	 * chunks at a time. E.g. while writing 4 * writesize bytes to a
+	 * device with 2 * writesize bytes buffer the MTD driver can (but
+	 * doesn't have to) do 2 writesize operations, but not 4.
+	 * In case of NAND flash writebufsize should be equivalent to
+	 * writesize. In case of NOR flash writebufsize is the size of the
+	 * write buffer used by the MTD device to program multiple bytes
+	 * at a time (in one programming operation).
+	 */
+	uint32_t writebufsize;
+
 	uint32_t oobsize;   // Amount of OOB data per block (e.g. 16)
 	uint32_t oobavail;  // Available OOB bytes per block