linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Han Xu <han.xu@nxp.com>
To: sean@geanix.com, frieder.schrempf@kontron.de, festevam@gmail.com
Cc: ye.li@nxp.com, peng.fan@nxp.com, han.xu@nxp.com,
	miquel.raynal@bootlin.com, linux-mtd@lists.infradead.org
Subject: [PATCH v4 2/5] mtd: rawnand: gpmi: Add strict ecc strength check
Date: Mon, 11 Apr 2022 21:52:43 -0500	[thread overview]
Message-ID: <20220412025246.24269-3-han.xu@nxp.com> (raw)
In-Reply-To: <20220412025246.24269-1-han.xu@nxp.com>

Add nand_ecc_is_strong_enough() check in gpmi_check_ecc() function to
make sure ecc strength can meet chip requirement.

Signed-off-by: Han Xu <han.xu@nxp.com>

---
Changes since v3:
 - split the uninline to a single patch
 - reuse the nand_ecc_is_strong_enough()

Changes since v2:
 - split the ecc check to a single patch
---
---
 drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
index 66ebd569858d..cee39126771e 100644
--- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
@@ -240,7 +240,13 @@ static void gpmi_dump_info(struct gpmi_nand_data *this)
 
 static inline bool gpmi_check_ecc(struct gpmi_nand_data *this)
 {
+	struct nand_chip *chip = &this->nand;
 	struct bch_geometry *geo = &this->bch_geometry;
+	struct nand_device *nand = &chip->base;
+	struct nand_ecc_props *conf = &nand->ecc.ctx.conf;
+
+	conf->step_size = geo->eccn_chunk_size;
+	conf->strength = geo->ecc_strength;
 
 	/* Do the sanity check. */
 	if (GPMI_IS_MXS(this)) {
@@ -248,7 +254,14 @@ 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;
+
+	if (!nand_ecc_is_strong_enough(nand))
+		return false;
+
+	return true;
 }
 
 /*
-- 
2.17.1


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

  parent reply	other threads:[~2022-04-12  2:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12  2:52 [PATCH v4 0/5] Refactor bch settings and support large oob NAND Han Xu
2022-04-12  2:52 ` [PATCH v4 1/5] mtd: rawnand: gpmi: Refactor bch geometry settings function Han Xu
2022-04-21  7:37   ` Miquel Raynal
2022-04-12  2:52 ` Han Xu [this message]
2022-04-21  7:37   ` [PATCH v4 2/5] mtd: rawnand: gpmi: Add strict ecc strength check Miquel Raynal
2022-04-12  2:52 ` [PATCH v4 3/5] mtd: rawnand: gpmi: Uninline the gpmi_check_ecc function Han Xu
2022-04-21  7:37   ` Miquel Raynal
2022-04-12  2:52 ` [PATCH v4 4/5] mtd: rawnand: gpmi: Rename the variable ecc_chunk_size Han Xu
2022-04-21  7:36   ` Miquel Raynal
2022-04-12  2:52 ` [PATCH v4 5/5] mtd: rawnand: gpmi: Add large oob bch setting support Han Xu
2022-04-21  7:36   ` 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=20220412025246.24269-3-han.xu@nxp.com \
    --to=han.xu@nxp.com \
    --cc=festevam@gmail.com \
    --cc=frieder.schrempf@kontron.de \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --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;
as well as URLs for NNTP newsgroup(s).