Skip to contentSkip to conversation

Single bit error correction on NAND.

DISCUSSION DataCom - Virgílio 2 participants 4 messages Jul 28, 2005 – Jul 29, 2005 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

I have noticed that NAND support on MTD can detect/correct single bit errors in 256 bytes, using software ECC. However, the correct data is not written back to flash. In other words, the bit stays "flipped" in flash. Isn't that dangerous? I mean, if another bitflip occurs in the same 256 bytes, we won't be able to correct by software ECC...

Am I missing something here? Thanks in advance.

Signature · 1 line
Virgílio Silva
#1 lore raw
Quoted 7 lines · DataCom - Virgílio

I have noticed that NAND support on MTD can detect/correct single bit errors in 256 bytes, using software ECC. However, the correct data is not written back to flash. In other words, the bit stays "flipped" in flash. Isn't that dangerous? I mean, if another bitflip occurs in the same 256 bytes, we won't be able to correct by software ECC...

Am I missing something here?

Yes.

It is not and can not be the responsibility of the NAND driver to handle this. Where to should it write the data ? The existing data _cannot_ be overwritten, without erasing the whole eraseblock and the implied risk of loosing _ALL_ the data on the block due to a powerfail.

The NAND driver returns the corrected data and an appropriate error code and the calling (e.g. filesystem) driver has to deal with the data copying or whatever the developer has decided to be the correct solution.

The NAND driver provides only the lowest level of access to the flash device.

tglx

#2 lore raw
Quoted 9 lines · Thomas Gleixner
Quoted 7 lines · DataCom - Virgílio

I have noticed that NAND support on MTD can detect/correct single bit errors in 256 bytes, using software ECC. However, the correct data is not written back to flash. In other words, the bit stays "flipped" in flash. Isn't that dangerous? I mean, if another bitflip occurs in the same 256 bytes, we won't be able to correct by software ECC...

Am I missing something here?

Quoted 8 lines

Yes.

It is not and can not be the responsibility of the NAND driver to handle this. Where to should it write the data ? The existing data _cannot_ be overwritten, without erasing the whole eraseblock and the implied risk of loosing _ALL_ the data on the block due to a powerfail.

The NAND driver returns the corrected data and an appropriate error code

Maybe I'm missing something, but the function nand_do_read_ecc returns -EBADMSG only if an uncorrectable error is detected by nand_correct_data. If just one bit is flipped, nand_correct_data corrects it, and nand_do_read_ecc returns 0.

Quoted 3 lines

and the calling (e.g. filesystem) driver has to deal with the data copying or whatever the developer has decided to be the correct solution.

So it would be JFFS2 responsability to write back the correct data to flash, after a bit-flip is detected and corrected by the NAND driver. However, apparently it doesn't.

My question is: do you think it's safe to just leave the bit flipped in flash? I mean, everytime I try to read it, ECC will handle it. But what are the odds of another bit-flip in the same 256 bytes?

Signature · 1 line
VIRGÍLIO Silva
#3 lore raw
Quoted 11 lines · DataCom - Virgílio
Quoted 6 lines

It is not and can not be the responsibility of the NAND driver to handle this. Where to should it write the data ? The existing data _cannot_ be overwritten, without erasing the whole eraseblock and the implied risk of loosing _ALL_ the data on the block due to a powerfail.

The NAND driver returns the corrected data and an appropriate error code

Maybe I'm missing something, but the function nand_do_read_ecc returns -EBADMSG only if an uncorrectable error is detected by nand_correct_data. If just one bit is flipped, nand_correct_data corrects it, and nand_do_read_ecc returns 0.

Damn, you're right. I check into this.

tglx