All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: YouChing Lin <ycllin@mxic.com.tw>
To: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
	juliensu@mxic.com.tw, YouChing Lin <ycllin@mxic.com.tw>
Subject: [PATCH 2/2] mtd: nand: ecc-hamming: Fix the double counting of ECC stat
Date: Tue, 11 May 2021 09:40:35 +0800	[thread overview]
Message-ID: <1620697235-7829-3-git-send-email-ycllin@mxic.com.tw> (raw)
In-Reply-To: <1620697235-7829-1-git-send-email-ycllin@mxic.com.tw>

If you use SPI-NAND with SW-ECC engine, the ECC related statistics
(ecc_stats.failed & ecc_stats.corrected) will be doubled, because
those numbers will be double-counted in ecc-sw-hamming.c and
drivers/mtd/nand/spi/core.c.

This can be found by using nandtest/nandbiterrs validation.

Signed-off-by: YouChing Lin <ycllin@mxic.com.tw>
---
 drivers/mtd/nand/ecc-sw-hamming.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/ecc-sw-hamming.c b/drivers/mtd/nand/ecc-sw-hamming.c
index a7655b6..e8a30cf 100644
--- a/drivers/mtd/nand/ecc-sw-hamming.c
+++ b/drivers/mtd/nand/ecc-sw-hamming.c
@@ -625,11 +625,12 @@ static int nand_ecc_sw_hamming_finish_io_req(struct nand_device *nand,
 							&ecccode[i],
 							&ecccalc[i]);
 		if (stat < 0) {
-			mtd->ecc_stats.failed++;
-		} else {
-			mtd->ecc_stats.corrected += stat;
-			max_bitflips = max_t(unsigned int, max_bitflips, stat);
+			nand_ecc_restore_req(&engine_conf->req_ctx, req);
+
+			return -EBADMSG;
 		}
+
+		max_bitflips = max_t(unsigned int, max_bitflips, stat);
 	}
 
 	nand_ecc_restore_req(&engine_conf->req_ctx, req);
-- 
1.9.1


WARNING: multiple messages have this Message-ID (diff)
From: YouChing Lin <ycllin@mxic.com.tw>
To: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
	juliensu@mxic.com.tw, YouChing Lin <ycllin@mxic.com.tw>
Subject: [PATCH 2/2] mtd: nand: ecc-hamming: Fix the double counting of ECC stat
Date: Tue, 11 May 2021 09:40:35 +0800	[thread overview]
Message-ID: <1620697235-7829-3-git-send-email-ycllin@mxic.com.tw> (raw)
In-Reply-To: <1620697235-7829-1-git-send-email-ycllin@mxic.com.tw>

If you use SPI-NAND with SW-ECC engine, the ECC related statistics
(ecc_stats.failed & ecc_stats.corrected) will be doubled, because
those numbers will be double-counted in ecc-sw-hamming.c and
drivers/mtd/nand/spi/core.c.

This can be found by using nandtest/nandbiterrs validation.

Signed-off-by: YouChing Lin <ycllin@mxic.com.tw>
---
 drivers/mtd/nand/ecc-sw-hamming.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/ecc-sw-hamming.c b/drivers/mtd/nand/ecc-sw-hamming.c
index a7655b6..e8a30cf 100644
--- a/drivers/mtd/nand/ecc-sw-hamming.c
+++ b/drivers/mtd/nand/ecc-sw-hamming.c
@@ -625,11 +625,12 @@ static int nand_ecc_sw_hamming_finish_io_req(struct nand_device *nand,
 							&ecccode[i],
 							&ecccalc[i]);
 		if (stat < 0) {
-			mtd->ecc_stats.failed++;
-		} else {
-			mtd->ecc_stats.corrected += stat;
-			max_bitflips = max_t(unsigned int, max_bitflips, stat);
+			nand_ecc_restore_req(&engine_conf->req_ctx, req);
+
+			return -EBADMSG;
 		}
+
+		max_bitflips = max_t(unsigned int, max_bitflips, stat);
 	}
 
 	nand_ecc_restore_req(&engine_conf->req_ctx, req);
-- 
1.9.1


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

  parent reply	other threads:[~2021-05-11  2:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-11  1:40 [PATCH 0/2] Fix double counting of S/W ECC engines' ECC stat YouChing Lin
2021-05-11  1:40 ` YouChing Lin
2021-05-11  1:40 ` [PATCH 1/2] mtd: nand: ecc-bch: Fix the double counting of " YouChing Lin
2021-05-11  1:40   ` YouChing Lin
2021-05-11  1:40 ` YouChing Lin [this message]
2021-05-11  1:40   ` [PATCH 2/2] mtd: nand: ecc-hamming: " YouChing Lin
2021-05-11  8:53 ` [PATCH 0/2] Fix double counting of S/W ECC engines' " Miquel Raynal
2021-05-11  8:53   ` Miquel Raynal
2021-05-13  2:11   ` ycllin
2021-05-13  2:11     ` ycllin
2021-05-13  6:45     ` Miquel Raynal
2021-05-13  6:45       ` Miquel Raynal
2021-05-20 10:56       ` ycllin
2021-05-20 10:56         ` ycllin

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=1620697235-7829-3-git-send-email-ycllin@mxic.com.tw \
    --to=ycllin@mxic.com.tw \
    --cc=juliensu@mxic.com.tw \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.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.