UBI crashes / fixing NAND subpage writes

Jon Povey Jon.Povey at racelogic.co.uk
Wed Sep 1 03:40:23 EDT 2010


I have been playing with UBI/UBIFS on 2KB page NAND, on TI DaVinci DM355 and having crashes due to subpage write problems.

ubiattach with -O 2048 avoids the problem, but I want to fix it, and use the flash more efficiently in space and time.

The DaVinci family generate 10 bytes of ECC in hardware for each 512 bytes of data; on 2KB page NAND the 4x10 bytes of ECC are concatenated together at the end of a page.

The problem is that the ECC generated for an all-FFs page is not all-FFs, and subpage writes are handled by nand_do_write_ops() by writing a full page with FFs in the unset data areas.

When UBI attaches it detects the subpage size as 512 bytes and tries to do two subpage writes, which results in two writes of (different) non-FF ECC data, causing corrupt ECC. An ubiattach, ubidetach, ubiattach sequence puts the kernel into a loop torturing the same block over and over, repeating these lines:

UBI error: ubi_io_read: error -74 while reading 512 bytes from PEB 2:512, read 512 bytes
UBI error: ubi_io_read: error -74 while reading 512 bytes from PEB 263:512, read 512 bytes
UBI: run torture test for PEB 263
UBI: PEB 263 passed torture test, do not mark it a bad

I hacked around this as a proof-of-concept by checking for an all-FF subpage in nand_write_page_hwecc() and setting that subpage's ECC to all-FFs, which works - I can attach, detatch, reattach, mount, write files, etc.

Of course this is not a very good solution. The right thing to do would seem to be make nand_do_write_ops() properly subpage aware and either add start and end offsets to the nand_write_page* family of functions, or add a nand_write_subpage* family of functions.

I don't mind having a go at some of this but am not confident to start such major overhaul of nand_base.c without at least seeking comment from others, so: This email. Maybe there's already something being worked on?

Comments welcome...

--
Jon Povey
jon.povey at racelogic.co.uk

Racelogic is a limited company registered in England. Registered number 2743719 .
Registered Office Unit 10, Swan Business Centre, Osier Way, Buckingham, Bucks, MK18 1TB .

The information contained in this electronic mail transmission is intended by Racelogic Ltd for the use of the named individual or entity to which it is directed and may contain information that is confidential or privileged. If you have received this electronic mail transmission in error, please delete it from your system without copying or forwarding it, and notify the sender of the error by reply email so that the sender's address records can be corrected. The views expressed by the sender of this communication do not necessarily represent those of Racelogic Ltd. Please note that Racelogic reserves the right to monitor e-mail communications passing through its network





More information about the linux-mtd mailing list