[PATCH] fix root cause of NAND trouble

Ben Dooks ben at trinity.fluff.org
Sun Nov 2 13:38:06 CET 2008


On Sun, Nov 02, 2008 at 12:31:53PM +0000, Ben Dooks wrote:
> On Sat, Nov 01, 2008 at 07:50:54PM -0200, Werner Almesberger wrote:
> > Ben Dooks wrote:
> > > My only comment would be
> > > that a slightly better solution would be to do:
> > 
> > Oh, that's much better, thanks ! I hadn't realized at first that
> > once could read the FIFO one byte at a time.
> > 
> > The revised patch is below.
> > 
> > - Werner
> > 
> > ---------------------------------- cut here -----------------------------------
> > 
> > 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 19:25:11.000000000 -0200
> > +++ ktrack/drivers/mtd/nand/s3c2410.c	2008-11-01 19:38:07.000000000 -0200
> > @@ -530,7 +530,12 @@
> >  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);
> > +	u8 *ptr = buf + (len & ~3);
> > +	int i;
> > +
> >  	readsl(info->regs + S3C2440_NFDATA, buf, len / 4);
> > +	for (i = 0; i != (len & 3); i++)
> > +		ptr[i] = readb(info->regs + S3C2440_NFDATA);
> >  }
> 
> actually, thinking about it, we can probably get better code by doing:
> 
> 	/* mop up any non-word aligned length reads. */
> 	for (i = (len & ~3); i != len; i++)
> 		ptr[i] = readb(info->regs + S3C2440_NFDATA);

of course, that should have been buf[i].
 
> this removes the need for the extra ptr variable, the comment is also
> useful.
> 
> >  static void s3c2410_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
> > 
> 
> -- 
> -- 
> Ben
> 
> Q:      What's a light-year?
> A:      One-third less calories than a regular year.
> 
> 

-- 
-- 
Ben

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




More information about the openmoko-kernel mailing list