From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Brian Norris <computersforpeace@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>,
linux-mtd@lists.infradead.org, Andrea Scian <rnd4@dave-tech.it>,
Richard Weinberger <richard@nod.at>
Subject: Re: [RESEND PATCH v3 4/5] mtd: nand: make 'erased check' optional
Date: Tue, 22 Sep 2015 10:04:13 +0200 [thread overview]
Message-ID: <20150922100413.1c5e8710@bbrezillon> (raw)
In-Reply-To: <20150921233021.GH31505@google.com>
Hi Brian,
On Mon, 21 Sep 2015 16:30:21 -0700
Brian Norris <computersforpeace@gmail.com> wrote:
> On Thu, Sep 03, 2015 at 06:03:41PM +0200, Boris Brezillon wrote:
> > Some ECC controllers do not need the extra 'erased check' done by the core.
> > Make it optional by creating a new NAND_ECC_DISABLE_ERASED_CHECK flag.
> >
> > Reed-Solomon ECC engines are guaranteed to generate ff ECC bytes when the
> > page in empty and are thus able to fix bitflips in erased pages.
> >
> > The software BCH implementation is also generating ff ECC bytes for empty
> > pages, and is thus able to fix bitflips in erased pages too.
> >
> > Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> > ---
> > drivers/mtd/nand/nand_base.c | 20 ++++++++++++++++----
> > drivers/mtd/nand/r852.c | 1 +
> > drivers/mtd/nand/tmio_nand.c | 1 +
> > drivers/mtd/nand/txx9ndfmc.c | 1 +
> > include/linux/mtd/nand.h | 8 ++++++++
> > 5 files changed, 27 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> > index 9a109a5..3be312d 100644
> > --- a/drivers/mtd/nand/nand_base.c
> > +++ b/drivers/mtd/nand/nand_base.c
> > @@ -1419,7 +1419,8 @@ 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) {
> > + if (stat == -EBADMSG &&
> > + !(chip->ecc.options & NAND_ECC_DISABLE_ERASED_CHECK)) {
> > /* check for empty pages with bitflips */
> > stat = nand_check_erased_ecc_chunk(p, chip->ecc.size,
> > &chip->buffers->ecccode[i],
> > @@ -1477,7 +1478,8 @@ 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) {
> > + if (stat == -EBADMSG &&
> > + !(chip->ecc.options & NAND_ECC_DISABLE_ERASED_CHECK)) {
> > /* check for empty pages with bitflips */
> > stat = nand_check_erased_ecc_chunk(p, eccsize,
> > &ecc_code[i], eccbytes,
> > @@ -1537,7 +1539,8 @@ 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) {
> > + if (stat == -EBADMSG &&
> > + !(chip->ecc.options & NAND_ECC_DISABLE_ERASED_CHECK)) {
> > /* check for empty pages with bitflips */
> > stat = nand_check_erased_ecc_chunk(p, eccsize,
> > &ecc_code[i], eccbytes,
> > @@ -1600,7 +1603,8 @@ static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
> > oob += chip->ecc.postpad;
> > }
> >
> > - if (stat == -EBADMSG) {
> > + if (stat == -EBADMSG &&
> > + !(chip->ecc.options & NAND_ECC_DISABLE_ERASED_CHECK)) {
> > /* check for empty pages with bitflips */
> > stat = nand_check_erased_ecc_chunk(p, chip->ecc.size,
> > oob - eccstepsize,
> > @@ -4300,6 +4304,14 @@ int nand_scan_tail(struct mtd_info *mtd)
> > ecc->write_oob_raw = ecc->write_oob;
> >
> > /*
> > + * The software implementation does not need the the erased check
> > + * since they already generate ff pattern for an erased page.
> > + */
> > + if (ecc->correct == nand_bch_correct_data ||
> > + ecc->correct == nand_correct_data)
> > + ecc->options |= NAND_ECC_DISABLE_ERASED_CHECK;
> > +
> > + /*
> > * The number of bytes available for a client to place data into
> > * the out of band area.
> > */
> > diff --git a/drivers/mtd/nand/r852.c b/drivers/mtd/nand/r852.c
> > index c9ad7a0..b82e4d9 100644
> > --- a/drivers/mtd/nand/r852.c
> > +++ b/drivers/mtd/nand/r852.c
> > @@ -876,6 +876,7 @@ static int r852_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
> > chip->ecc.hwctl = r852_ecc_hwctl;
> > chip->ecc.calculate = r852_ecc_calculate;
> > chip->ecc.correct = r852_ecc_correct;
> > + chip->ecc.options |= NAND_ECC_DISABLE_ERASED_CHECK;
>
> Maybe a comment here as to why? (e.g., something about hamming?)
Yep, I'll add a comment explaining why we put this flag.
[...]
> > diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
> > index 19d43b1..88956ab 100644
> > --- a/include/linux/mtd/nand.h
> > +++ b/include/linux/mtd/nand.h
> > @@ -128,6 +128,13 @@ typedef enum {
> > #define NAND_ECC_WRITE 1
> > /* Enable Hardware ECC before syndrome is read back from flash */
> > #define NAND_ECC_READSYN 2
> > +/*
> > + * Disable NAND 'page erased' check. In any case, this check is only done when
> > + * ecc.correct() returns -EBADMSG.
> > + * Set this flag if your implementation is able to fix bitflips in erased
> > + * pages.
> > + */
> > +#define NAND_ECC_DISABLE_ERASED_CHECK BIT(1)
>
> Any good reason you start at BIT(1) instead of BIT(0)?
Nope. I'll fix that too.
Best Regards,
Boris
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
next prev parent reply other threads:[~2015-09-22 8:04 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
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 [this message]
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=20150922100413.1c5e8710@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--cc=rnd4@dave-tech.it \
/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.