linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd/nand:Fix wrong usage of is_blank() in fsl_ifc_run_command
@ 2012-01-18  4:13 Prabhakar Kushwaha
  2012-01-20 20:20 ` Scott Wood
  2012-01-27 13:15 ` Artem Bityutskiy
  0 siblings, 2 replies; 4+ messages in thread
From: Prabhakar Kushwaha @ 2012-01-18  4:13 UTC (permalink / raw)
  To: linuxppc-dev, linux-mtd; +Cc: Scott Wood, Poonam Aggrwal, Prabhakar Kushwaha

Freescale IFC NAND Machine calculates ECC on 512byte sector and same is used in
fsl_ifc_run_command() during ECC status verification. Also this sector is passed
to is_blank() for blank checking. It is wrong at first place because
is_blank()'s implementation checks for Page size and OOB area size. 
is_blank() should be called per page for main and OOB area verification.

Variables name are redefined to avoid confusion between buffer and ecc sector.

Signed-off-by: Poonam Aggrwal <poonam.aggrwal@freescale.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
---
 git://git.kernel.org/pub/scm/linux/kernel/git/galak/powerpc.git (branch next)

 Tested on P1010RDB

 This patch is created on top of IFC driver patch (already floated in mailing
 list). Please find their link:
 http://patchwork.ozlabs.org/patch/133315/
 http://patchwork.ozlabs.org/patch/133316/

 This patch is replacement of my earlier patch
  "mtd/nand:Fix wrong address read in is_blank()"

 drivers/mtd/nand/fsl_ifc_nand.c |   52 +++++++++++++++++++++------------------
 1 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c
index 854fe95..33b55d2 100644
--- a/drivers/mtd/nand/fsl_ifc_nand.c
+++ b/drivers/mtd/nand/fsl_ifc_nand.c
@@ -1,7 +1,7 @@
 /*
  * Freescale Integrated Flash Controller NAND driver
  *
- * Copyright 2011 Freescale Semiconductor, Inc
+ * Copyright 2011,2012 Freescale Semiconductor, Inc
  *
  * Author: Dipen Dudhat <Dipen.Dudhat@freescale.com>
  *
@@ -216,24 +216,11 @@ static int check_read_ecc(struct mtd_info *mtd, struct fsl_ifc_ctrl *ctrl,
 			  u32 *eccstat, unsigned int bufnum)
 {
 	u32 reg = eccstat[bufnum / 4];
-	int errors = (reg >> ((3 - bufnum % 4) * 8)) & 15;
+	int errors;
 
-	if (errors == 15) { /* uncorrectable */
-		/* Blank pages fail hw ECC checks */
-		if (is_blank(mtd, bufnum))
-			return 1;
+	errors = (reg >> ((3 - bufnum % 4) * 8)) & 15;
 
-		/*
-		 * We disable ECCER reporting in hardware due to
-		 * erratum IFC-A002770 -- so report it now if we
-		 * see an uncorrectable error in ECCSTAT.
-		 */
-		ctrl->nand_stat |= IFC_NAND_EVTER_STAT_ECCER;
-	} else if (errors > 0) {
-		mtd->ecc_stats.corrected += errors;
-	}
-
-	return 0;
+	return errors;
 }
 
 /*
@@ -273,16 +260,33 @@ static void fsl_ifc_run_command(struct mtd_info *mtd)
 		dev_err(priv->dev, "NAND Flash Write Protect Error\n");
 
 	if (nctrl->eccread) {
-		int bufperpage = mtd->writesize / 512;
-		int bufnum = (nctrl->page & priv->bufnum_mask) * bufperpage;
-		int bufnum_end = bufnum + bufperpage - 1;
+		int errors;
+		int bufnum = nctrl->page & priv->bufnum_mask;
+		int sector = bufnum * chip->ecc.steps;
+		int sector_end = sector + chip->ecc.steps - 1;
 
-		for (i = bufnum / 4; i <= bufnum_end / 4; i++)
+		for (i = sector / 4; i <= sector_end / 4; i++)
 			eccstat[i] = in_be32(&ifc->ifc_nand.nand_eccstat[i]);
 
-		for (i = bufnum; i <= bufnum_end; i++) {
-			if (check_read_ecc(mtd, ctrl, eccstat, i))
+		for (i = sector; i <= sector_end; i++) {
+			errors = check_read_ecc(mtd, ctrl, eccstat, i);
+
+			if (errors == 15) {
+				/*
+				 * Uncorrectable error.
+				 * OK only if the whole page is blank.
+				 *
+				 * We disable ECCER reporting due to...
+				 * erratum IFC-A002770 -- so report it now if we
+				 * see an uncorrectable error in ECCSTAT.
+				 */
+				if (!is_blank(mtd, bufnum))
+					ctrl->nand_stat |=
+						IFC_NAND_EVTER_STAT_ECCER;
 				break;
+			}
+
+			mtd->ecc_stats.corrected += errors;
 		}
 
 		nctrl->eccread = 0;
-- 
1.7.5.4

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

* Re: [PATCH] mtd/nand:Fix wrong usage of is_blank() in fsl_ifc_run_command
  2012-01-18  4:13 [PATCH] mtd/nand:Fix wrong usage of is_blank() in fsl_ifc_run_command Prabhakar Kushwaha
@ 2012-01-20 20:20 ` Scott Wood
  2012-01-27 13:15 ` Artem Bityutskiy
  1 sibling, 0 replies; 4+ messages in thread
From: Scott Wood @ 2012-01-20 20:20 UTC (permalink / raw)
  To: Prabhakar Kushwaha; +Cc: linux-mtd, linuxppc-dev, Poonam Aggrwal

On 01/17/2012 10:13 PM, Prabhakar Kushwaha wrote:
> +		for (i = sector; i <= sector_end; i++) {
> +			errors = check_read_ecc(mtd, ctrl, eccstat, i);
> +
> +			if (errors == 15) {
> +				/*
> +				 * Uncorrectable error.
> +				 * OK only if the whole page is blank.
> +				 *
> +				 * We disable ECCER reporting due to...

s/due to.../due to/

Otherwise looks good.

-Scott

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

* Re: [PATCH] mtd/nand:Fix wrong usage of is_blank() in fsl_ifc_run_command
  2012-01-18  4:13 [PATCH] mtd/nand:Fix wrong usage of is_blank() in fsl_ifc_run_command Prabhakar Kushwaha
  2012-01-20 20:20 ` Scott Wood
@ 2012-01-27 13:15 ` Artem Bityutskiy
  2012-01-27 14:20   ` Kushwaha Prabhakar-B32579
  1 sibling, 1 reply; 4+ messages in thread
From: Artem Bityutskiy @ 2012-01-27 13:15 UTC (permalink / raw)
  To: Prabhakar Kushwaha; +Cc: Scott Wood, linux-mtd, linuxppc-dev, Poonam Aggrwal

[-- Attachment #1: Type: text/plain, Size: 816 bytes --]

On Wed, 2012-01-18 at 09:43 +0530, Prabhakar Kushwaha wrote:
> Freescale IFC NAND Machine calculates ECC on 512byte sector and same is used in
> fsl_ifc_run_command() during ECC status verification. Also this sector is passed
> to is_blank() for blank checking. It is wrong at first place because
> is_blank()'s implementation checks for Page size and OOB area size. 
> is_blank() should be called per page for main and OOB area verification.
> 
> Variables name are redefined to avoid confusion between buffer and ecc sector.
> 
> Signed-off-by: Poonam Aggrwal <poonam.aggrwal@freescale.com>
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>

The driver is not in 3.3-rc1, so I skip this patch.

-- 
Best Regards,
Artem Bityutskiy

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* RE: [PATCH] mtd/nand:Fix wrong usage of is_blank() in fsl_ifc_run_command
  2012-01-27 13:15 ` Artem Bityutskiy
@ 2012-01-27 14:20   ` Kushwaha Prabhakar-B32579
  0 siblings, 0 replies; 4+ messages in thread
From: Kushwaha Prabhakar-B32579 @ 2012-01-27 14:20 UTC (permalink / raw)
  To: dedekind1@gmail.com
  Cc: linux-mtd@lists.infradead.org, Aggrwal Poonam-B10812,
	linuxppc-dev@lists.ozlabs.org, Wood Scott-B07421

DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogQXJ0ZW0gQml0eXV0c2tp
eSBbbWFpbHRvOmRlZGVraW5kMUBnbWFpbC5jb21dDQo+IFNlbnQ6IEZyaWRheSwgSmFudWFyeSAy
NywgMjAxMiA2OjQ2IFBNDQo+IFRvOiBLdXNod2FoYSBQcmFiaGFrYXItQjMyNTc5DQo+IENjOiBs
aW51eHBwYy1kZXZAbGlzdHMub3psYWJzLm9yZzsgbGludXgtbXRkQGxpc3RzLmluZnJhZGVhZC5v
cmc7IFdvb2QNCj4gU2NvdHQtQjA3NDIxOyBBZ2dyd2FsIFBvb25hbS1CMTA4MTINCj4gU3ViamVj
dDogUmU6IFtQQVRDSF0gb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ieTogUHJh
Ymhha2FyIEt1c2h3YWhhIDxwcmFiaGFrYXJAZnJlZXNjYWxlLmNvbT4NCj4gDQo+IFRoZSBkcml2
ZXIgaXMgbm90IGluIDMuMy1yYzEsIHNvIEkgc2tpcCB0aGlzIHBhdGNoLg0KPiANCg0KDQpUaGlz
IHBhdGNoIGlzIHNxdWFzaGVkIGluIExpbnV4IE5BTkQgZHJpdmVyIHBhdGNoLiBJdCB3aWxsIGJl
IHByb3ZpZGVkIGJ5IGdhbGFrJ3MgdHJlZQ0KDQoiTkFORCBNYWNoaW5lIHN1cHBvcnQgZm9yIElu
dGVncmF0ZWQgRmxhc2ggQ29udHJvbGxlciINCmh0dHA6Ly9wYXRjaHdvcmsub3psYWJzLm9yZy9w
YXRjaC8xMzcwMjQvDQoNCi0tUHJhYmhha2FyDQoNCg==

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

end of thread, other threads:[~2012-01-27 14:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-18  4:13 [PATCH] mtd/nand:Fix wrong usage of is_blank() in fsl_ifc_run_command Prabhakar Kushwaha
2012-01-20 20:20 ` Scott Wood
2012-01-27 13:15 ` Artem Bityutskiy
2012-01-27 14:20   ` Kushwaha Prabhakar-B32579

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