All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Han Xu <han.xu@nxp.com>
Cc: sean@geanix.com, frieder.schrempf@kontron.de, festevam@gmail.com,
	ye.li@nxp.com, peng.fan@nxp.com, linux-mtd@lists.infradead.org
Subject: Re: [PATCH v3 2/4] mtd: rawnand: gpmi: Add strict ecc strength check
Date: Tue, 5 Apr 2022 09:28:26 +0200	[thread overview]
Message-ID: <20220405092826.1f70fb70@xps13> (raw)
In-Reply-To: <20220404195427.8871-2-han.xu@nxp.com>

Hi Han,

han.xu@nxp.com wrote on Mon,  4 Apr 2022 14:54:25 -0500:

> Add strict ecc strength check in gpmi_check_ecc() function, which is
> same as nand_ecc_is_strong_enough() did. It will check both correct bits
> and correct bits per byte to ensure it meets chip required ecc strength.
> 
> Signed-off-by: Han Xu <han.xu@nxp.com>
> 
> ---
> Changes since v2:
>  - split the ecc check to a single patch
> ---
> ---
>  drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 24 ++++++++++++++++++++--
>  1 file changed, 22 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
> index 4144d5937103..9a37f8cc663e 100644
> --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
> @@ -238,9 +238,14 @@ static void gpmi_dump_info(struct gpmi_nand_data *this)
>  		geo->block_mark_bit_offset);
>  }
>  
> -static inline bool gpmi_check_ecc(struct gpmi_nand_data *this)
> +static bool gpmi_check_ecc(struct gpmi_nand_data *this)

This change should be in a separate commit.

>  {
> +	struct nand_chip *chip = &this->nand;
> +	struct mtd_info *mtd = nand_to_mtd(&this->nand);
>  	struct bch_geometry *geo = &this->bch_geometry;
> +	const struct nand_ecc_props *requirements =
> +		nanddev_get_ecc_requirements(&chip->base);
> +	int corr, ds_corr;
>  
>  	/* Do the sanity check. */
>  	if (GPMI_IS_MXS(this)) {
> @@ -248,7 +253,22 @@ static inline bool gpmi_check_ecc(struct gpmi_nand_data *this)
>  		if (geo->gf_len == 14)
>  			return false;
>  	}
> -	return geo->ecc_strength <= this->devdata->bch_max_ecc_strength;
> +
> +	if (geo->ecc_strength > this->devdata->bch_max_ecc_strength)
> +		return false;
> +
> +	/* check ecc strength, same as nand_ecc_is_strong_enough() did */

Why not using nand_ecc_is_strong_enough() in this case?

> +	if (requirements->step_size) {
> +		corr = mtd->writesize * geo->ecc_strength /
> +		       geo->ecc_chunk_size;
> +		ds_corr = mtd->writesize * requirements->strength /
> +			  requirements->step_size;
> +		if (corr < ds_corr ||
> +		    geo->ecc_strength < requirements->strength)
> +			return false;
> +	}
> +
> +	return true;
>  }
>  
>  /*


Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2022-04-05  7:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-04 19:54 [PATCH v3 1/4] mtd: rawnand: gpmi: Refactor bch geometry settings function Han Xu
2022-04-04 19:54 ` [PATCH v3 2/4] mtd: rawnand: gpmi: Add strict ecc strength check Han Xu
2022-04-05  7:28   ` Miquel Raynal [this message]
2022-04-08 22:05     ` Han Xu
2022-04-11  7:30       ` Miquel Raynal
2022-04-04 19:54 ` [PATCH v3 3/4] mtd: rawnand: gpmi: Rename the variable ecc_chunk_size Han Xu
2022-04-05  7:29   ` Miquel Raynal
2022-04-04 19:54 ` [PATCH v3 4/4] mtd: rawnand: gpmi: Add large oob bch setting support Han Xu
2022-04-05  7:26 ` [PATCH v3 1/4] mtd: rawnand: gpmi: Refactor bch geometry settings function Miquel Raynal

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=20220405092826.1f70fb70@xps13 \
    --to=miquel.raynal@bootlin.com \
    --cc=festevam@gmail.com \
    --cc=frieder.schrempf@kontron.de \
    --cc=han.xu@nxp.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=peng.fan@nxp.com \
    --cc=sean@geanix.com \
    --cc=ye.li@nxp.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.