public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Ben Dooks <ben-linux@fluff.org>
To: Werner Almesberger <werner@openmoko.org>
Cc: linux-mtd@lists.infradead.org, Ben Dooks <ben@trinity.fluff.org>
Subject: Re: [PATCH] nand_read_subpage vs. S3C244x NAND: non-word reads
Date: Sat, 1 Nov 2008 12:46:34 +0000	[thread overview]
Message-ID: <20081101124634.GB11063@fluff.org.uk> (raw)
In-Reply-To: <20081101031505.GA5177@almesberger.net>

On Sat, Nov 01, 2008 at 01:15:05AM -0200, Werner Almesberger wrote:
> In recent kernels, the optimized OOB reads in nand_read_subpage often
> make requests which aren't an exact multiple of a word, which caused
> nand/s3c2410.c to do a partial read, yielding chaos and mayhem.
> 
> I'm not entirely sure whether nand_read_subpage is to blame for making
> non-word requests, or whether nand/s3c2410.c is to blame for not
> supporting them, but here's a patch for the latter.

As noted on the openmoko list, I think we can do 256byte subpage reads
as long as they are aligned to 256bytes. We could make the ECC code
deal with non-256 byte power-of-two aligned blocks without huge
changes but my belief is that we cannot support anything that isn't
a power of two.

I think the best thing to do is to either force the caller to read
a power of two (pref. >4 bytes), so either we need some form of flag
to say this, or change the behaviour of the callers to never try this.
 
> Note that s3c2410_nand_write_buf has a similar issue. RNDIN is used in
> nand_write_oob_syndrome, so this may also be a real problems.
> 
> - 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@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);
> +	}

note you'll still fail for len in the 0..3 region, as you'll move
len+4 bytes, and then copy them over the data you just read.

>  }
>  
>  static void s3c2410_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
> 
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/

-- 
Ben (ben@fluff.org, http://www.fluff.org/)

  'a smiley only costs 4 bytes'

  reply	other threads:[~2008-11-01 12:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-01  3:15 [PATCH] nand_read_subpage vs. S3C244x NAND: non-word reads Werner Almesberger
2008-11-01 12:46 ` Ben Dooks [this message]
2008-11-01 16:11   ` Werner Almesberger
2008-11-02 12:27     ` Ben Dooks

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081101124634.GB11063@fluff.org.uk \
    --to=ben-linux@fluff.org \
    --cc=ben@trinity.fluff.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=werner@openmoko.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox