public inbox for linux-mtd@lists.infradead.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 1/4] mtd: rawnand: gpmi: Refactor bch geometry settings function
Date: Tue, 5 Apr 2022 09:26:14 +0200	[thread overview]
Message-ID: <20220405092614.037e9715@xps13> (raw)
In-Reply-To: <20220404195427.8871-1-han.xu@nxp.com>

Hi Han,

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

> The code change refactor the bch geometry setting function, which still
> use the legacy bch setting as default option, while user may choose to
> use chips required minimum ecc strength by DT flag "fsl,use-minimum-ecc".
> 
> The driver uses legacy bch geometry settings by default, if the NAND

Shall we really refer to a legacy geometry? It's just that there was a
default value until know, you need another default for bigger devices,
but the ancient geometry is still completely valid (at least for
existing devices).

Can you change the naming? You can however mention in a comment
that this way of deriving the geometry is deprecated for larger devices
(and mention the split).

Otherwise LGTM.

> chips oob size is less than 1KB. The legacy_set_geometry() sets the data
> chunk size(step_size) larger than oob size to make sure BBM locates in
> data chunk, then set the maximum ecc strength oob can hold. It always use
> unbalanced ECC layout, which ecc0 will cover both meta and data0 chunk.
> 
> For all other cases,set the bch geometry by chip required strength and
> step size, which uses the minimum ecc strength chip required. It can be
> explicitly enabled by DT flag "fsl,use-minimum-ecc", but need to be
> en/disabled in both u-boot and kernel at the same time.
> 
> Signed-off-by: Han Xu <han.xu@nxp.com>
> Tested-by: Sean Nyekjaer <sean@geanix.com>
> 
> ---
> Changes since v2
>  - split the ecc check to a single patch
> 
> Changes since v1
>  - split the patch to two parts
>  - change the commit log
>  - add test tag
> ---
> ---
>  drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 32 ++++++++++++++--------
>  1 file changed, 20 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
> index d96899fa90b7..4144d5937103 100644
> --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
> @@ -514,24 +514,32 @@ static int legacy_set_geometry(struct gpmi_nand_data *this)
>  static int common_nfc_set_geometry(struct gpmi_nand_data *this)
>  {
>  	struct nand_chip *chip = &this->nand;
> +	struct mtd_info *mtd = nand_to_mtd(&this->nand);
>  	const struct nand_ecc_props *requirements =
>  		nanddev_get_ecc_requirements(&chip->base);
> +	bool use_minimun_ecc;
> +	int err;
>  
> -	if (chip->ecc.strength > 0 && chip->ecc.size > 0)
> -		return set_geometry_by_ecc_info(this, chip->ecc.strength,
> -						chip->ecc.size);
> -
> -	if ((of_property_read_bool(this->dev->of_node, "fsl,use-minimum-ecc"))
> -				|| legacy_set_geometry(this)) {
> -		if (!(requirements->strength > 0 && requirements->step_size > 0))
> -			return -EINVAL;
> +	use_minimun_ecc = of_property_read_bool(this->dev->of_node,
> +						"fsl,use-minimum-ecc");
>  
> -		return set_geometry_by_ecc_info(this,
> -						requirements->strength,
> -						requirements->step_size);
> +	/* use legacy bch geometry settings by default*/
> +	if ((!use_minimun_ecc && mtd->oobsize < 1024) ||
> +	    !(requirements->strength > 0 && requirements->step_size > 0)) {
> +		dev_dbg(this->dev, "use legacy bch geometry\n");
> +		err = legacy_set_geometry(this);
> +		if (!err)
> +			return 0;
>  	}
>  
> -	return 0;
> +	/* otherwise use the minimum ecc nand chip required */
> +	dev_dbg(this->dev, "use minimum ecc bch geometry\n");
> +	err = set_geometry_by_ecc_info(this, requirements->strength,
> +					requirements->step_size);
> +	if (err)
> +		dev_err(this->dev, "none of the bch geometry setting works\n");
> +
> +	return err;
>  }
>  
>  /* Configures the geometry for BCH.  */


Thanks,
Miquèl

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

      parent 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
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 ` Miquel Raynal [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=20220405092614.037e9715@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox