From: Brian Norris <computersforpeace@gmail.com>
To: Mike Scherban <m-scherban@ti.com>
Cc: linux-mtd@lists.infradead.org, dwmw2@infradead.org,
m-karicheri2@ti.com, nsekhar@ti.com,
Boris Brezillon <boris.brezillon@free-electrons.com>
Subject: Re: [RESEND PATCH] mtd: davinci-nand: correct empty sector bit flips
Date: Mon, 2 Nov 2015 09:52:30 -0800 [thread overview]
Message-ID: <20151102175230.GA9515@localhost> (raw)
In-Reply-To: <1446483557-31098-1-git-send-email-m-scherban@ti.com>
+ Boris
On Mon, Nov 02, 2015 at 10:59:17AM -0600, Mike Scherban wrote:
> Currently empty page bit flips are not corrected and report 0 errors.
> If there happens to be a bit flip, this will cause UBIFS to fail to
> mount with a "corruption in empty space" error. The only way to recover
> from this is to reflash the NAND partition.
>
> This changes the empty page handling to count the number of bit flips
> and correct them if they are under or equal to the ECC strength. UBI
> will then resolve the mounting error without requiring a reflash.
>
> Signed-off-by: Mike Scherban <m-scherban@ti.com>
> ---
> drivers/mtd/nand/davinci_nand.c | 21 ++++++++++++++++++---
> 1 file changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c
> index feb6d18..8189d8a 100644
> --- a/drivers/mtd/nand/davinci_nand.c
> +++ b/drivers/mtd/nand/davinci_nand.c
> @@ -316,12 +316,27 @@ static int nand_davinci_correct_4bit(struct mtd_info *mtd,
> unsigned num_errors, corrected;
> unsigned long timeo;
>
> - /* All bytes 0xff? It's an erased page; ignore its ECC. */
> - for (i = 0; i < 10; i++) {
> + /* All bytes 0xff? It's an erased page;
> + * Ignore its ECC, but check for bit flips.
> + */
> + for (i = 0; i < info->chip.ecc.bytes; i++) {
> if (ecc_code[i] != 0xff)
> goto compare;
> }
> - return 0;
> +
> + /* Count bit flips in empty space. */
> + for (i = 0, corrected = 0; i < info->chip.ecc.size; i++)
> + corrected += hweight8(~data[i]);
> +
> + /* If bit flips are above the ecc strength produce an error */
> + if (corrected > info->chip.ecc.strength)
> + return -EIO;
> +
> + /* If there are bit flips correct the data */
> + if (corrected)
> + memset(data, 0xff, info->chip.ecc.size);
> +
> + return corrected;
NAK. We don't need any more badly-done local hacks (it's not enough to
just check the in-band data bytes; you have to check the spare area
too). Please review/test this instead:
http://lists.infradead.org/pipermail/linux-mtd/2015-September/061617.html
http://thread.gmane.org/gmane.linux.drivers.mtd/61358
Regards,
Brian
>
> compare:
> /* Unpack ten bytes into eight 10 bit values. We know we're
> --
> 1.7.9.5
>
prev parent reply other threads:[~2015-11-02 17:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-02 16:59 [RESEND PATCH] mtd: davinci-nand: correct empty sector bit flips Mike Scherban
2015-11-02 17:52 ` Brian Norris [this message]
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=20151102175230.GA9515@localhost \
--to=computersforpeace@gmail.com \
--cc=boris.brezillon@free-electrons.com \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=m-karicheri2@ti.com \
--cc=m-scherban@ti.com \
--cc=nsekhar@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.