[PATCH] fix root cause of NAND trouble

Ben Dooks ben-linux at fluff.org
Sat Nov 1 13:35:42 CET 2008


On Sat, Nov 01, 2008 at 01:02:26AM -0200, Werner Almesberger wrote:
> Let's start a new thread. I changed the old one too many times :-)
> 
> The problem wasn't the offset but the length. I'm not entirely sure
> if the NAND driver is to blame for not handling non-word requests or
> if the NAND stack is to blame for ever producing them. My bet would
> be on the NAND driver, but I'll ask on the mtd list.
> 
> This patch obsoletes bandaid-bogus-nand-ecc-read.patch
> 
> - Werner

> fix-s3c-nand-read-bytes.patch
> 
> With the introduction of optimized OOB reads in nand_read_subpage,
> the length of the data requested may not be a multiple of four bytes.
> 
> This caused a partial read on the 2440, leading to false ECC errors
> and, worse, attempts to "correct" them.
> 
> Note that there is a similar issue in s3c2440_nand_write_buf, which
> doesn't seem to cause trouble yet.
> 
> Signed-off-by: Werner Almesberger <werner at openmoko.org>
> 
> ---
> 
> Index: ktrack/drivers/mtd/nand/s3c2410.c
> ===================================================================
> --- ktrack.orig/drivers/mtd/nand/s3c2410.c	2008-11-01 00:29:45.000000000 -0200
> +++ ktrack/drivers/mtd/nand/s3c2410.c	2008-11-01 00:38:10.000000000 -0200
> @@ -530,7 +530,14 @@
>  static void s3c2440_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
>  {
>  	struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
> +
>  	readsl(info->regs + S3C2440_NFDATA, buf, len / 4);
> +	if (unlikely(len & 3)) {
> +		u32 data;
> +
> +		data = readl(info->regs + S3C2440_NFDATA);
> +		memcpy(buf + (len & ~3), &data, len & 3);
> +	}

If you are getting unaligned reads, then there isn't much hope for
correctly assessing the ECC code, which we generally (unless you've
overriden it) is expecting 256byte blocks. 

The normal NAND ECC scheme can cope with an power-of-two read correctly
although we don't currently support correcting anything other than 256
byte blocks in the ECC scheme being used by the S3C24XX driver. I think
the best thing to do is to try and ensure the MTD layer never tries an
anything other than 256 byte read from an nand page until the ECC code
can be updated.

-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.




More information about the openmoko-kernel mailing list