linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: rawnand: micron: Update ecc_stats.corrected
@ 2018-06-20  7:44 Boris Brezillon
  2018-06-20  7:58 ` Miquel Raynal
  0 siblings, 1 reply; 4+ messages in thread
From: Boris Brezillon @ 2018-06-20  7:44 UTC (permalink / raw)
  To: Boris Brezillon, Richard Weinberger, Miquel Raynal, linux-mtd
  Cc: David Woodhouse, Brian Norris, Marek Vasut

Even if we can't update ecc_stats.corrected with an accurate value we
should at least increase the number of bitflips so that MTD users can
know that there was some bitflips.

Just add chip->ecc.strength to mtd->ecc_stats.corrected which should
account for the worst case situation.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
---
 drivers/mtd/nand/raw/nand_micron.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/mtd/nand/raw/nand_micron.c b/drivers/mtd/nand/raw/nand_micron.c
index 5ec4c90a637d..203faba0a9c1 100644
--- a/drivers/mtd/nand/raw/nand_micron.c
+++ b/drivers/mtd/nand/raw/nand_micron.c
@@ -137,18 +137,19 @@ micron_nand_read_page_on_die_ecc(struct mtd_info *mtd, struct nand_chip *chip,
 	if (ret)
 		goto out;
 
-	if (status & NAND_STATUS_FAIL)
+	if (status & NAND_STATUS_FAIL) {
 		mtd->ecc_stats.failed++;
-
-	/*
-	 * The internal ECC doesn't tell us the number of bitflips
-	 * that have been corrected, but tells us if it recommends to
-	 * rewrite the block. If it's the case, then we pretend we had
-	 * a number of bitflips equal to the ECC strength, which will
-	 * hint the NAND core to rewrite the block.
-	 */
-	else if (status & NAND_STATUS_WRITE_RECOMMENDED)
+	} else if (status & NAND_STATUS_WRITE_RECOMMENDED) {
+		/*
+		 * The internal ECC doesn't tell us the number of bitflips
+		 * that have been corrected, but tells us if it recommends to
+		 * rewrite the block. If it's the case, then we pretend we had
+		 * a number of bitflips equal to the ECC strength, which will
+		 * hint the NAND core to rewrite the block.
+		 */
+		mtd->ecc_stats.corrected += chip->ecc.strength;
 		max_bitflips = chip->ecc.strength;
+	}
 
 	ret = nand_read_data_op(chip, buf, mtd->writesize, false);
 	if (!ret && oob_required)
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: rawnand: micron: Update ecc_stats.corrected
  2018-06-20  7:44 [PATCH] mtd: rawnand: micron: Update ecc_stats.corrected Boris Brezillon
@ 2018-06-20  7:58 ` Miquel Raynal
  2018-06-20  8:04   ` Boris Brezillon
  0 siblings, 1 reply; 4+ messages in thread
From: Miquel Raynal @ 2018-06-20  7:58 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Richard Weinberger, linux-mtd, David Woodhouse, Brian Norris,
	Marek Vasut

Hi Boris,

On Wed, 20 Jun 2018 09:44:43 +0200, Boris Brezillon
<boris.brezillon@bootlin.com> wrote:

> Even if we can't update ecc_stats.corrected with an accurate value we
> should at least increase the number of bitflips so that MTD users can
> know that there was some bitflips.
> 
> Just add chip->ecc.strength to mtd->ecc_stats.corrected which should
> account for the worst case situation.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> ---

Shouldn't we consider this change as a fix?

Thanks,
Miquèl

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: rawnand: micron: Update ecc_stats.corrected
  2018-06-20  7:58 ` Miquel Raynal
@ 2018-06-20  8:04   ` Boris Brezillon
  2018-06-25 12:35     ` Miquel Raynal
  0 siblings, 1 reply; 4+ messages in thread
From: Boris Brezillon @ 2018-06-20  8:04 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Richard Weinberger, linux-mtd, David Woodhouse, Brian Norris,
	Marek Vasut

On Wed, 20 Jun 2018 09:58:43 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> Hi Boris,
> 
> On Wed, 20 Jun 2018 09:44:43 +0200, Boris Brezillon
> <boris.brezillon@bootlin.com> wrote:
> 
> > Even if we can't update ecc_stats.corrected with an accurate value we
> > should at least increase the number of bitflips so that MTD users can
> > know that there was some bitflips.
> > 
> > Just add chip->ecc.strength to mtd->ecc_stats.corrected which should
> > account for the worst case situation.
> > 
> > Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> > ---  
> 
> Shouldn't we consider this change as a fix?

It's not really fixing a bug, in that ecc_stats.corrected are already
not accurate, they just give a hint about how often you fix bitflips
on a NAND device. But if you think it should be backported, I can add
the Fixes and Cc-stable tags.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: rawnand: micron: Update ecc_stats.corrected
  2018-06-20  8:04   ` Boris Brezillon
@ 2018-06-25 12:35     ` Miquel Raynal
  0 siblings, 0 replies; 4+ messages in thread
From: Miquel Raynal @ 2018-06-25 12:35 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Richard Weinberger, linux-mtd, David Woodhouse, Brian Norris,
	Marek Vasut

Hi Boris,

On Wed, 20 Jun 2018 10:04:44 +0200, Boris Brezillon
<boris.brezillon@bootlin.com> wrote:

> On Wed, 20 Jun 2018 09:58:43 +0200
> Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> 
> > Hi Boris,
> > 
> > On Wed, 20 Jun 2018 09:44:43 +0200, Boris Brezillon
> > <boris.brezillon@bootlin.com> wrote:
> >   
> > > Even if we can't update ecc_stats.corrected with an accurate value we
> > > should at least increase the number of bitflips so that MTD users can
> > > know that there was some bitflips.
> > > 
> > > Just add chip->ecc.strength to mtd->ecc_stats.corrected which should
> > > account for the worst case situation.
> > > 
> > > Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> > > ---    
> > 
> > Shouldn't we consider this change as a fix?  
> 
> It's not really fixing a bug, in that ecc_stats.corrected are already
> not accurate, they just give a hint about how often you fix bitflips
> on a NAND device. But if you think it should be backported, I can add
> the Fixes and Cc-stable tags.
> 

It's fine for me.

Applied to nand/next.

Thanks,
Miquèl

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-06-25 12:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-20  7:44 [PATCH] mtd: rawnand: micron: Update ecc_stats.corrected Boris Brezillon
2018-06-20  7:58 ` Miquel Raynal
2018-06-20  8:04   ` Boris Brezillon
2018-06-25 12:35     ` Miquel Raynal

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).