From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: David Woodhouse <dwmw2@infradead.org>,
Brian Norris <computersforpeace@gmail.com>,
linux-mtd@lists.infradead.org, Andrea Scian <rnd4@dave-tech.it>,
Richard Weinberger <richard@nod.at>
Subject: Re: [PATCH v2 0/2] mtd: nand: properly handle bitflips in erased pages
Date: Wed, 2 Sep 2015 14:46:03 +0200 [thread overview]
Message-ID: <20150902144603.1612c26d@bbrezillon> (raw)
In-Reply-To: <1440409642-5495-1-git-send-email-boris.brezillon@free-electrons.com>
Brian,
On Mon, 24 Aug 2015 11:47:20 +0200
Boris Brezillon <boris.brezillon@free-electrons.com> wrote:
> Hello,
>
> This patch series aims at providing a common logic to check for bitflips
> in erased pages.
Could we settle on something regarding this problem?
I need that feature for the sunxi NAND driver, and we can't agree on
something I'll have to implement my own private function to do that...
>
> Currently each driver is implementing its own logic to check for bitflips
> in erased pages. Not only this create code duplication, but most of these
> implementations are incorrect.
> Here are a few aspects that are often left aside in those implementations:
> 1/ they do not check OOB bytes when checking for the ff pattern, which
> means they can consider a page as empty while the MTD user actually
> wanted to write almost ff with a few bits to zero
> 2/ they check for the ff pattern on the whole page, while ECC actually
> works on smaller chunks (usually 512 or 1024 bytes chunks)
> 3/ they use random bitflip thresholds to decide whether a page/chunk is
> erased or not. IMO this threshold should be set to ECC strength (or
> at least something correlated to this parameter)
>
> The approach taken in this series is to provide two helper functions to
> check for bitflips in erased pages. Each driver that needs to check for
> such cases can then call the nand_check_erased_ecc_chunk() function, and
> rely on the common logic to decide whether a page is erased or not.
>
> While Brian suggested a few times to make this detection automatic for
> all drivers that set a specific flag (NAND_CHECK_ERASED_BITFLIPS?), here
> is a few reasons I think this is not such a good idea:
> 1/ some (a lot of) drivers do not properly implement the raw access
> functions, and since we need to check for raw data and OOB bytes this
> makes the automatic detection unusable for most drivers unless they
> decide to correctly implement those methods (which would be a good
> thing BTW).
> 2/ as a I said earlier, this check should be made at the ECC chunk level
> and not at the page level. This spots two problems: some (a lot of)
> drivers do not properly specify the ecc layout information, and even
> if the ecc layout is correctly defined, there is no way to attach ECC
> bytes to a specific ECC chunk.
> 3/ the last aspect is the perf penalty incured by this test. Automatically
> doing that at the NAND core level implies reading the whole page again
> in raw mode, while with the helper function approach, drivers supporting
> access at the ECC chunk level can read only the faulty chunk in raw
> mode.
>
> Regarding the bitflips threshold at which an erased pages is considered as
> faulty, I have assigned it to ECC strength. As mentioned by Andrea, using
> ECC strength might cause some trouble, because if you already have some
> bitflips in an erased page, programming it might generate even more of
> them.
> In the other hand, shouldn't that be checked after (or before) programming
> a page. I mean, UBI is already capable of detecting pages which are over
> the configured bitflips_threshold and move data around when it detects
> such pages.
> If we check data after writing a page we wouldn't have to bother about
> setting a weaker value for the "bitflips in erased page" case.
> Another thing in favor of the ECC strength value for this "bitflips in
> erased page" threshold value: if the ECC engine is generating 0xff ECC
> bytes when the page is empty, then it will be able to fix ECC strength
> bitflips without complaining, so why should we use different value when
> we detect bitflips using the pattern match approach?
>
> Best Regards,
>
> Boris
>
> Changes since v1:
> - fix the nand_check_erased_buf() function
> - mark the bitflips > bitflips_threshold condition as unlikely
> - add missing memsets in nand_check_erased_ecc_chunk()
>
> Boris Brezillon (2):
> mtd: nand: add nand_check_erased helper functions
> mtd: nand: use nand_check_erased_ecc_chunk in default ECC read
> functions
>
> drivers/mtd/nand/nand_base.c | 170 +++++++++++++++++++++++++++++++++++++++++--
> include/linux/mtd/nand.h | 8 ++
> 2 files changed, 171 insertions(+), 7 deletions(-)
>
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
next prev parent reply other threads:[~2015-09-02 12:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-24 9:47 [PATCH v2 0/2] mtd: nand: properly handle bitflips in erased pages Boris Brezillon
2015-08-24 9:47 ` [PATCH v2 1/2] mtd: nand: add nand_check_erased helper functions Boris Brezillon
2015-09-02 18:41 ` Brian Norris
2015-09-02 19:30 ` Boris Brezillon
2015-09-02 20:26 ` Brian Norris
2015-09-02 20:51 ` Boris Brezillon
2015-09-03 13:22 ` Andrea Scian
2015-08-24 9:47 ` [PATCH v2 2/2] mtd: nand: use nand_check_erased_ecc_chunk in default ECC read functions Boris Brezillon
2015-09-02 20:35 ` Brian Norris
2015-09-02 20:45 ` Boris Brezillon
2015-09-02 12:46 ` Boris Brezillon [this message]
2015-09-02 19:43 ` [PATCH v2 0/2] mtd: nand: properly handle bitflips in erased pages Brian Norris
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=20150902144603.1612c26d@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox