[NAND flash driver] What would mtd do if read returns -EBADMSG (ecc failed)

Artem Bityutskiy dedekind at infradead.org
Tue Oct 21 03:09:54 EDT 2008


On Tue, 2008-10-21 at 14:51 +0800, Du Zhongdong wrote:
> I got another question: if, in my nand flash driver, there's an ECC
> error cannot be corrected during a read procedure, I think now the
> block should be marked as a bad block

Read errors do not indicate that the block became bad. For example, if
you write twice (and different data) to the same NAND page, you'll
probably end up with ECC errors. But the block will not be bad.

For example, a silly user wrote something to /dev/mtd several times. And
you have many read errors. Is whole /dev/mtd bad? No, it does not.

> , then two options:
> 1, I mark that block BAD in my nand flash driver(specifically, I would
> insert some code in the nand_read() function in nand_base.c to handle
> this error);

Current model is so that MTD driver is not intelligent. It just reads,
writes, erases, etc when it is asked to. All bad block management is
done in upper layers. So this is not your driver's pain.

> 2, I return some error msg the upper layer(ie. MTD layer), which is
> what nand_read() do at present. Then I would expect the MTD layer
> would mark that block BAD.

Not the MTD layer, but stuff like UBI or JFFS2 - the _client_ of the MTD
layer.

> I read s3c2410.c and find that it chose option 2. But I can't find the
> place in the code where  the MTD layer mark that block BAD.

Right. MTD layer does not do this. It is stupid, and marks blocks as bad
only when someone calls mtd->block_markbad().

Think about MTD as the very low layer, which just provides the interface
to work with raw flash chip. Nothing else, no intelligence.

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)




More information about the linux-mtd mailing list