From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Abhishek Sahu <absahu@codeaurora.org>
Cc: Boris Brezillon <boris.brezillon@bootlin.com>,
David Woodhouse <dwmw2@infradead.org>,
Brian Norris <computersforpeace@gmail.com>,
Marek Vasut <marek.vasut@gmail.com>,
Richard Weinberger <richard@nod.at>,
linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mtd@lists.infradead.org, Andy Gross <andy.gross@linaro.org>,
Archit Taneja <architt@codeaurora.org>
Subject: Re: [PATCH v4 14/15] mtd: rawnand: qcom: erased page bitflips detection
Date: Tue, 26 Jun 2018 20:02:29 +0200 [thread overview]
Message-ID: <20180626200229.7f638f7e@xps13> (raw)
In-Reply-To: <1529479662-4026-15-git-send-email-absahu@codeaurora.org>
Hi Abhishek,
On Wed, 20 Jun 2018 12:57:41 +0530, Abhishek Sahu
<absahu@codeaurora.org> wrote:
> NAND parts can have bitflips in an erased page due to the
> process technology used. In this case, QCOM NAND controller
> is not able to identify that page as an erased page.
> Currently the driver calls nand_check_erased_ecc_chunk() for
> identifying the erased pages but this won’t work always since the
> checking is being with ECC engine returned data. In case of
> bitflips, the ECC engine tries to correct the data and then it
> generates the uncorrectable error. Now, this data is not equal to
> original raw data. For erased CW identification, the raw data
> should be read again from NAND device and this
> nand_check_erased_ecc_chunk function() should be called for raw
> data only.
>
> Now following logic is being added to identify the erased
> codeword bitflips.
>
> 1. In most of the cases, not all the codewords will have bitflips
> and only single CW will have bitflips. So, there is no need to
> read the complete raw page data. The NAND raw read can be
> scheduled for any CW in page. The NAND controller works on CW
> basis and it will update the status register after each CW read.
> Maintain the bitmask for the CW which generated the uncorrectable
> error.
> 2. Do raw read for all the CW's which generated the uncorrectable
> error.
> 3. Both DATA and OOB need to be checked for number of 0. The
> top-level API can be called with only data buf or OOB buf so use
> chip->databuf if data buf is null and chip->oob_poi if
> OOB buf is null for copying the raw bytes temporarily.
> 4. For each CW, check the number of 0 in cw_data and usable
> oob bytes, The bbm and spare (unused) bytes bit flip won’t
> affect the ECC so don’t check the number of bitflips in this area.
>
> Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
> ---
> * Changes from v3:
>
> 1. Major changes in erased codeword detection for
> raw read function
I really prefer this version, much more readable from my point of view!
>
> * Changes from v2:
> NONE
>
> * Changes from v1:
> 1. Minor change in commit message
> 2. invalidate pagebuf if databuf or oob_poi is used
>
> drivers/mtd/nand/raw/qcom_nandc.c | 127 +++++++++++++++++++++++++++-----------
> 1 file changed, 90 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
> index 160acdf..e34edf1 100644
> --- a/drivers/mtd/nand/raw/qcom_nandc.c
> +++ b/drivers/mtd/nand/raw/qcom_nandc.c
> @@ -1656,20 +1656,95 @@ static int check_flash_errors(struct qcom_nand_host *host, int cw_cnt)
> }
>
> /*
> + * Bitflips can happen in erased codewords also so this function counts the
> + * number of 0 in each CW for which ECC engine returns the uncorrectable
> + * error. The page will be assumed as erased if this count is less than or
> + * equal to the ecc->strength for each CW.
> + *
> + * 1. Both DATA and OOB need to be checked for number of 0. The
> + * top-level API can be called with only data buf or OOB buf so use
> + * chip->data_buf if data buf is null and chip->oob_poi if oob buf
> + * is null for copying the raw bytes.
> + * 2. Perform raw read for all the CW which has uncorrectable errors.
> + * 3. For each CW, check the number of 0 in cw_data and usable OOB bytes.
> + * The BBM and spare bytes bit flip won’t affect the ECC so don’t check
> + * the number of bitflips in this area.
> + */
> +static int
> +check_for_erased_page(struct qcom_nand_host *host, u8 *data_buf,
> + u8 *oob_buf, unsigned long uncorrectable_cws,
> + int page, unsigned int max_bitflips)
> +{
> + struct nand_chip *chip = &host->chip;
> + struct mtd_info *mtd = nand_to_mtd(chip);
> + struct nand_ecc_ctrl *ecc = &chip->ecc;
> + int cw, data_size, oob_size, ret = 0;
> +
> + if (!data_buf) {
> + data_buf = chip->data_buf;
> + chip->pagebuf = -1;
> + }
> +
> + if (!oob_buf) {
> + oob_buf = chip->oob_poi;
> + chip->pagebuf = -1;
> + }
> +
> + for (cw = 0; cw < ecc->steps && uncorrectable_cws; cw++) {
Last nitpick:
Could you have a look to bitmap.c and bitops.h and use a
for_each_set_bit() loop?
No need to resend all the patches, you can send a v5 just for this
patch, the others are fine for me.
Thanks,
Miquèl
next prev parent reply other threads:[~2018-06-26 18:02 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-20 7:27 [PATCH v4 00/15] Update for QCOM NAND driver Abhishek Sahu
2018-06-20 7:27 ` Abhishek Sahu
2018-06-20 7:27 ` [PATCH v4 01/15] mtd: rawnand: helper function for setting up ECC configuration Abhishek Sahu
2018-06-20 7:27 ` Abhishek Sahu
2018-06-25 2:23 ` Masahiro Yamada
2018-06-20 7:27 ` [PATCH v4 02/15] mtd: rawnand: denali: use helper function for ecc setup Abhishek Sahu
2018-06-20 7:27 ` Abhishek Sahu
2018-06-20 7:27 ` [PATCH v4 03/15] dt-bindings: qcom_nandc: update for ECC strength and step size Abhishek Sahu
2018-06-20 7:27 ` Abhishek Sahu
2018-06-20 16:01 ` Rob Herring
2018-06-20 7:27 ` [PATCH v4 04/15] mtd: rawnand: qcom: remove dt property nand-ecc-step-size Abhishek Sahu
2018-06-20 7:27 ` Abhishek Sahu
2018-06-20 7:27 ` [PATCH v4 05/15] mtd: rawnand: qcom: use the ecc strength from device parameter Abhishek Sahu
2018-06-20 7:27 ` Abhishek Sahu
2018-06-20 7:27 ` [PATCH v4 06/15] mtd: rawnand: qcom: wait for desc completion in all BAM channels Abhishek Sahu
2018-06-20 7:27 ` Abhishek Sahu
2018-06-20 7:27 ` [PATCH v4 07/15] mtd: rawnand: qcom: erased page detection for uncorrectable errors only Abhishek Sahu
2018-06-20 7:27 ` Abhishek Sahu
2018-06-20 7:27 ` [PATCH v4 08/15] mtd: rawnand: qcom: fix null pointer access for erased page detection Abhishek Sahu
2018-06-20 7:27 ` Abhishek Sahu
2018-06-20 7:27 ` [PATCH v4 09/15] mtd: rawnand: qcom: parse read errors for read oob also Abhishek Sahu
2018-06-20 7:27 ` Abhishek Sahu
2018-06-20 7:27 ` [PATCH v4 10/15] mtd: rawnand: qcom: modify write_oob to remove read codeword part Abhishek Sahu
2018-06-20 7:27 ` Abhishek Sahu
2018-06-20 7:27 ` [PATCH v4 11/15] mtd: rawnand: qcom: fix return value for raw page read Abhishek Sahu
2018-06-20 7:27 ` Abhishek Sahu
2018-06-20 7:27 ` [PATCH v4 12/15] mtd: rawnand: qcom: check for operation errors in case of raw read Abhishek Sahu
2018-06-20 7:27 ` Abhishek Sahu
2018-06-20 7:27 ` [PATCH v4 13/15] mtd: rawnand: qcom: code reorganization for " Abhishek Sahu
2018-06-20 7:27 ` Abhishek Sahu
2018-06-20 7:27 ` [PATCH v4 14/15] mtd: rawnand: qcom: erased page bitflips detection Abhishek Sahu
2018-06-20 7:27 ` Abhishek Sahu
2018-06-26 18:02 ` Miquel Raynal [this message]
2018-06-20 7:27 ` [PATCH v4 15/15] mtd: rawnand: provide only single helper function for ECC conf Abhishek Sahu
2018-06-20 7:27 ` Abhishek Sahu
2018-07-01 18:09 ` [PATCH v4 00/15] Update for QCOM NAND driver Miquel Raynal
2018-07-03 3:30 ` Abhishek Sahu
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=20180626200229.7f638f7e@xps13 \
--to=miquel.raynal@bootlin.com \
--cc=absahu@codeaurora.org \
--cc=andy.gross@linaro.org \
--cc=architt@codeaurora.org \
--cc=boris.brezillon@bootlin.com \
--cc=computersforpeace@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=richard@nod.at \
/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.