[Yaffs] yaffs2 oob offset problem

Charles Manning manningc2 at actrix.gen.nz
Wed Aug 3 22:15:29 BST 2005


On Wednesday 03 August 2005 21:39, Artis Kugevics wrote:
> Hello,
>
> I wonder, at what oob offset yaffs2 out-of-band data is placed for curent
> yaffs2 users? This offset is taken from default nand_oobinfo structure in
> MTD. If not overriden, then it is nand_oob_64 in mtd/nand/nand_base.c,
> which sets offset to 2 (oobfree = {{2,38}}).

Are you using the latest mtd from CVS? AFAIK this works fine. It has the code 
shown in the patch at the bottom.

>
> I personally, had to modify yaffs2 source, for it to work with such
> setting. Modification is necessarry, because that mtd->read_oob() call
> returns oob data from offset 0 (and not from offset 2, as specified by
> nand_oobinfo structure). My patch is attached for reference.

I know that this **was** a problem that Nick Bane pointed out to tglx over 2 
months ago. Thomas generated the attached patch. I have looked at the mtd CVS 
from about 2 weeks ago (1.146) and it seems to have this code in it.

I believe Nick Bane tried this out, it worked, and tglx applied it to CVS.

The way this is supposed to work with AUTOPLACE is as follows:
1) mtd tells YAFFS it will store a buffer of up to n bytes.
2) YAFFS does not care where these bytes are store, it just gives a buffer and 
says "write these"
3) mtd does all the byte shuffling in the OOB area according to whatever else 
it wants to do.
4) Same basic deal in reverse for reading.

That is the basic contract between YAFFS and mtd for AUTOPLACE. AUTOPLACE 
means just that: automatically place the oob spare data buffer.

If there is a corruption of OOB data, then mtd is broken.

If you have tried the latest CVS code, and it is still broken, then we need to 
go over to mtd and  beat up tglx.

-- Charles

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
NB: Don't use the patch below, I show it for reference only. Use the latest 
code instead!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Index: drivers/mtd/nand/nand_base.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/nand_base.c,v
retrieving revision 1.140
diff -u -r1.140 nand_base.c
--- drivers/mtd/nand/nand_base.c        4 Apr 2005 18:56:29 -0000       1.140
+++ drivers/mtd/nand/nand_base.c        12 May 2005 08:19:53 -0000
@@ -1195,7 +1195,8 @@
                }       
 
                /* get oob area, if we have no oob buffer from fs-driver */
-               if (!oob_buf || oobsel->useecc == MTD_NANDECC_AUTOPLACE)
+               if (!oob_buf || oobsel->useecc == MTD_NANDECC_AUTOPLACE ||
+                       oobsel->useecc == MTD_NANDECC_AUTOPL_USR)
                        oob_data = &this->data_buf[end];
 
                eccsteps = this->eccsteps;
@@ -1284,6 +1285,7 @@
                        /* without autoplace. Legacy mode used by YAFFS1 */
                        switch(oobsel->useecc) {
                        case MTD_NANDECC_AUTOPLACE:
+                       case MTD_NANDECC_AUTOPL_USR:
                                /* Walk through the autoplace chunks */
                                for (i = 0, j = 0; j < mtd->oobavail; i++) {
                                        int from = oobsel->oobfree[i][0];
@@ -1646,6 +1648,8 @@
                oobsel = this->autooob;
                autoplace = 1;
        }       
+       if (oobsel->useecc == MTD_NANDECC_AUTOPL_USR)
+               autoplace = 1;
 
        /* Setup variables and oob buffer */
        totalpages = len >> this->page_shift;
@@ -1920,6 +1924,8 @@
                oobsel = this->autooob;
                autoplace = 1;
        }       
+       if (oobsel->useecc == MTD_NANDECC_AUTOPL_USR)
+               autoplace = 1;
 
        /* Setup start page */
        page = (int) (to >> this->page_shift);
Index: include/mtd/mtd-abi.h
===================================================================
RCS file: /home/cvs/mtd/include/mtd/mtd-abi.h,v
retrieving revision 1.10
diff -u -r1.10 mtd-abi.h
--- include/mtd/mtd-abi.h       9 Feb 2005 09:17:42 -0000       1.10
+++ include/mtd/mtd-abi.h       12 May 2005 08:19:54 -0000
@@ -61,6 +61,7 @@
 #define MTD_NANDECC_PLACE      1       // Use the given placement in the 
structure (YAFFS1 legacy mode)
 #define MTD_NANDECC_AUTOPLACE  2       // Use the default placement scheme
 #define MTD_NANDECC_PLACEONLY  3       // Use the given placement in the 
structure (Do not store ecc result on read)
+#define MTD_NANDECC_AUTOPL_USR         4       // Use the given autoplacement 
scheme rather than using the default
 
 /* OTP mode selection */
 #define MTD_OTP_OFF            0



More information about the yaffs mailing list