All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: David Woodhouse <dwmw2@infradead.org>,
	linux-mtd@lists.infradead.org, Andrea Scian <rnd4@dave-tech.it>,
	Richard Weinberger <richard@nod.at>,
	Roger Quadros <rogerq@ti.com>,
	Pekon Gupta <pekon.gupta@gmail.com>,
	Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Subject: Re: [RESEND PATCH v3 3/5] mtd: nand: use nand_check_erased_ecc_chunk in default ECC read functions
Date: Mon, 21 Sep 2015 16:45:09 -0700	[thread overview]
Message-ID: <20150921234509.GI31505@google.com> (raw)
In-Reply-To: <1441296222-14989-4-git-send-email-boris.brezillon@free-electrons.com>

+ others

On Thu, Sep 03, 2015 at 06:03:40PM +0200, Boris Brezillon wrote:
> The default NAND read functions are relying on an underlying controller
> to correct bitflips, but some of those controller cannot properly fix
> bitflips in erased pages.
> In case of ECC failures, check if the page of subpage is empty before
> reporting an ECC failure.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>

I'd really want some test results for this before opting everyone in. If
I remember your last response correctly, you're just testing sunxi-nand,
which uses a different implementation, right?

Potential different strategy: if we can get one or two drivers to test
this, we could flip it around into an opt-in flag (this would
modify/eliminate patch 3). I know this has downsides for
less-actively-developed drivers, which may never get fixed up to support
erased-page ECC checks, but then, it also likely has less benefits for
those cases too.

Thoughts? I could be convinced another way if I we can get reasonable
backing from others who can test this.

One more comment below.

> ---
>  drivers/mtd/nand/nand_base.c | 50 +++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 43 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index a2687ea..9a109a5 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -1419,6 +1419,15 @@ static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,
>  
>  		stat = chip->ecc.correct(mtd, p,
>  			&chip->buffers->ecccode[i], &chip->buffers->ecccalc[i]);
> +		if (stat == -EBADMSG) {
> +			/* check for empty pages with bitflips */
> +			stat = nand_check_erased_ecc_chunk(p, chip->ecc.size,
> +						&chip->buffers->ecccode[i],
> +						chip->ecc.bytes,
> +						NULL, 0,
> +						chip->ecc.strength);
> +		}
> +
>  		if (stat < 0) {
>  			mtd->ecc_stats.failed++;
>  		} else {
> @@ -1468,6 +1477,14 @@ static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
>  		int stat;
>  
>  		stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]);
> +		if (stat == -EBADMSG) {
> +			/* check for empty pages with bitflips */
> +			stat = nand_check_erased_ecc_chunk(p, eccsize,
> +						&ecc_code[i], eccbytes,
> +						NULL, 0,
> +						chip->ecc.strength);
> +		}
> +
>  		if (stat < 0) {
>  			mtd->ecc_stats.failed++;
>  		} else {
> @@ -1520,6 +1537,14 @@ static int nand_read_page_hwecc_oob_first(struct mtd_info *mtd,
>  		chip->ecc.calculate(mtd, p, &ecc_calc[i]);
>  
>  		stat = chip->ecc.correct(mtd, p, &ecc_code[i], NULL);
> +		if (stat == -EBADMSG) {
> +			/* check for empty pages with bitflips */
> +			stat = nand_check_erased_ecc_chunk(p, eccsize,
> +						&ecc_code[i], eccbytes,
> +						NULL, 0,
> +						chip->ecc.strength);
> +		}
> +
>  		if (stat < 0) {
>  			mtd->ecc_stats.failed++;
>  		} else {
> @@ -1547,6 +1572,8 @@ static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
>  	int i, eccsize = chip->ecc.size;
>  	int eccbytes = chip->ecc.bytes;
>  	int eccsteps = chip->ecc.steps;
> +	int eccstepsize = eccsize + eccbytes + chip->ecc.prepad +
> +			  chip->ecc.postpad;

Hmm, is this correct? I think you shouldn't be adding in eccsize, if
you're looking for just the length of the ECC OOB region. But I could be
wrong.

>  	uint8_t *p = buf;
>  	uint8_t *oob = chip->oob_poi;
>  	unsigned int max_bitflips = 0;
> @@ -1566,19 +1593,28 @@ static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
>  		chip->read_buf(mtd, oob, eccbytes);
>  		stat = chip->ecc.correct(mtd, p, oob, NULL);
>  
> -		if (stat < 0) {
> -			mtd->ecc_stats.failed++;
> -		} else {
> -			mtd->ecc_stats.corrected += stat;
> -			max_bitflips = max_t(unsigned int, max_bitflips, stat);
> -		}
> -
>  		oob += eccbytes;
>  
>  		if (chip->ecc.postpad) {
>  			chip->read_buf(mtd, oob, chip->ecc.postpad);
>  			oob += chip->ecc.postpad;
>  		}
> +
> +		if (stat == -EBADMSG) {
> +			/* check for empty pages with bitflips */
> +			stat = nand_check_erased_ecc_chunk(p, chip->ecc.size,
> +							   oob - eccstepsize,
> +							   eccstepsize,
> +							   NULL, 0,
> +							   chip->ecc.strength);
> +		}
> +
> +		if (stat < 0) {
> +			mtd->ecc_stats.failed++;
> +		} else {
> +			mtd->ecc_stats.corrected += stat;
> +			max_bitflips = max_t(unsigned int, max_bitflips, stat);
> +		}
>  	}
>  
>  	/* Calculate remaining oob bytes */

Brian

  reply	other threads:[~2015-09-21 23:45 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-03 16:03 [RESEND PATCH v3 0/5] mtd: nand: properly handle bitflips in erased pages Boris Brezillon
2015-09-03 16:03 ` [RESEND PATCH v3 1/5] mtd: nand: add nand_check_erased helper functions Boris Brezillon
2015-09-16  7:54   ` Boris Brezillon
2015-09-21 22:45   ` Brian Norris
2015-09-03 16:03 ` [RESEND PATCH v3 2/5] mtd: nand: return consistent error codes in ecc.correct() implementations Boris Brezillon
2015-09-21 23:10   ` Brian Norris
2015-09-22  7:54     ` Boris Brezillon
2015-09-03 16:03 ` [RESEND PATCH v3 3/5] mtd: nand: use nand_check_erased_ecc_chunk in default ECC read functions Boris Brezillon
2015-09-21 23:45   ` Brian Norris [this message]
2015-09-22  8:02     ` Boris Brezillon
2015-09-03 16:03 ` [RESEND PATCH v3 4/5] mtd: nand: make 'erased check' optional Boris Brezillon
2015-09-03 17:19   ` Boris Brezillon
2015-09-21 23:30   ` Brian Norris
2015-09-22  8:04     ` Boris Brezillon
2015-09-03 16:03 ` [RESEND PATCH v3 5/5] mtd: nand: remove custom 'erased check' implementation Boris Brezillon
2015-09-21 23:28   ` Brian Norris
2015-09-22  8:08     ` Boris Brezillon

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=20150921234509.GI31505@google.com \
    --to=computersforpeace@gmail.com \
    --cc=boris.brezillon@free-electrons.com \
    --cc=dwmw2@infradead.org \
    --cc=ezequiel.garcia@free-electrons.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=pekon.gupta@gmail.com \
    --cc=richard@nod.at \
    --cc=rnd4@dave-tech.it \
    --cc=rogerq@ti.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.