[PATCH 1/2] mtd: nand: add OOB argument to NAND {read, write}_page interfaces

Bastian Hecht hechtb at googlemail.com
Wed Apr 25 09:17:17 EDT 2012


2012/4/24 Shmulik Ladkani <shmulik.ladkani at gmail.com>:
> Hi Bastian,
>
> On Mon, 23 Apr 2012 11:14:39 +0200 Bastian Hecht <hechtb at googlemail.com> wrote:
>> Following this thread, I wondered how mtd_write_oob is meant to work.
>> The sh_flctl code simply writes the OOB data 1 to 1 into the oob area
>> of the nand chip when using hardware ECC. So when reading this, it
>> should result in a corrupted page. Is the driver meant to OR the ECC
>> code to the buffer? Then the driver would need a page read and write
>> it back applying the oob data, no?

Hello Schmulik,

> The beahvior is dependent on mtd_oob_ops->mode.
>
> If mode is MTD_OPS_AUTO_OOB, 'nand_fill_oob' places the user provided
> 'oobbuf' into the "free" locations within the OOB layout (as defined by
> 'chip->ecc.layout->oobfree').
> Implementor of 'chip->ecc.write_page' is expected to take care of ECC
> caclulation and fill the ECC bytes (driver's or HW responsibility).
>
> If the mode is MTD_OPS_RAW, user provided 'oobbuf' should be transferred
> as-is, without error correction ('chip->ecc.write_page_raw' will be
> invoked).

Ahaa. Thanks for elaborating this, now I understand how things are
supposed to work. You helped me to catch a flaw in the code, thanks! I
have to introduce a flag or similar to turn off the on-the-fly ECC
generation when the _raw functions are used.

Best regards,

 Bastian Hecht

> If the mode is MTD_OPS_PLACE_OOB, then 'nand_fill_oob' copies user's
> 'oobbuf' onto 'oob_poi'.
> As with MTD_OPS_AUTO_OOB, implementor of 'chip->ecc.write_page' is
> expected to take care of ECC calculation; the ECC locations are assumed
> to be overwritten (ignoring user's bytes at the ECC locations).
>
> This is according to the nand_base.c default methods.
> For example, you can follow nand_do_write_ops, nand_write_page,
> nand_write_page_swecc.
>
> Regards,
> Shmulik



More information about the linux-mtd mailing list