[PATCH 1/2] mtd: nand: add erased-page bitflip correction

Ezequiel Garcia ezequiel.garcia at free-electrons.com
Thu Mar 13 08:57:17 EDT 2014


On Mar 12, Brian Norris wrote:
> Hi Pekon,
> 
> On Thu, Mar 13, 2014 at 05:55:32AM +0000, Pekon Gupta wrote:
> > >From: Brian Norris [mailto:computersforpeace at gmail.com]
> > >On Wed, Mar 12, 2014 at 01:45:15PM +0100, Elie De Brauwer wrote:
> > >> b) "determining you read an erased page". In case of the i.mx (and
> > >> thus GPMI) the BCH block can tell you three things:
> > >>  1. I read all 0xff's
> > >>  2. I read some data and nothing got corrected
> > >>  3. I read something but failed to correct it.
> > >> The third case can have two causes:
> > >>  3.a you read valid data with bitflips exceeding what the BCH could
> > >> correct
> > >>  3.b you read an erased page with bitflips.
> > >>
> > >> Obviously case 3.b is what this discussion is all about, and my quest
> > >> revolved around a means to quickly identify case '3.b'.
> > >
> > >Yes, 3.a vs. 3.b is the big problem.
> [...]
> 
> > I think for OMAP NAND driver there needs to be some help on "1." also.
> > There is no hardware support in GPMC (Ti's controller) to find out if the
> > (read_data + read_oob) == 0xff. So you have to do this comparison in
> > software.
> 
> Really? So if you read a blank (all 0xff) page that has no bitflips, you
> see an ECC error? I'm sorry, but I didn't realize that's how your
> hardware worked. That's the worst hardware ECC design I've seen so far
> :(
> 

I haven't had time to follow this discussion yet, but just wanted to point
out the above is also true for pxa3xx-nand.c.

If a completely erased page is read, the calculated ECC would be 0 and the
stored ECC would be all 0xff (although I never actually checked this).
See the snippet below:

static int pxa3xx_nand_read_page_hwecc(struct mtd_info *mtd,
		struct nand_chip *chip, uint8_t *buf, int oob_required,
		int page)
{
	[..]
	} else if (info->retcode == ERR_UNCORERR) {
		/*
		 * for blank page (all 0xff), HW will calculate its ECC as
		 * 0, which is different from the ECC information within
		 * OOB, ignore such uncorrectable errors
		 */
		if (is_buf_blank(buf, mtd->writesize))
			info->retcode = ERR_NONE;
	}
	[..]
}

-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com



More information about the linux-mtd mailing list