mtd/nand:Fix wrong usage of is_blank() in fsl_ifc_run_command
Subsystems (2)
PATCH 1/1 mtd/nand:Fix wrong usage of is_blank() in fsl_ifc_run_command
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.
---
Applied upon git://git.denx.de/u-boot.git (branch master)
This patch is based upon ifc driver patch in linuxppc-dev mailing list
http://patchwork.ozlabs.org/patch/136547/
It is a replacement of my earlier patch
"mtd/nand:Fix wrong address read in is_blank()"
http://patchwork.ozlabs.org/patch/133388/
drivers/mtd/nand/fsl_ifc_nand.c | 52 +++++++++++++++++++++------------------ 1 files changed, 28 insertions(+), 24 deletions(-)
drivers/mtd/nand/fsl_ifc_nand.c +28 -24
@@ -1,6 +1,6 @@/* Integrated Flash Controller NAND Machine Driver * -* Copyright (c) 2011 Freescale Semiconductor, Inc +* Copyright (c) 2012 Freescale Semiconductor, Inc * * Authors: Dipen Dudhat <[email protected]> *
@@ -221,24 +221,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 ; - -if (errors ==15 ) {/* uncorrectable */ -/* Blank pages fail hw ECC checks */ -if (is_blank (mtd, ctrl, bufnum)) -return 1 ; - -/* -* We disable ECCER reporting in hardware due to -* erratum IFC-A002770 -- so report it now if we -* see an uncorrectable error in ECCSTAT. -*/ - ctrl->status |=IFC_NAND_EVTER_STAT_ECCER ; - }else if (errors >0 ) { - mtd->ecc_stats.corrected += errors; - } +int errors; -return 0 ; + errors = (reg >> ((3 - bufnum %4 ) *8 )) &15 ; + +return errors; }/*
@@ -279,16 +266,33 @@ static int fsl_ifc_run_command(struct mtd_info *mtd)printf ("%s: Write Protect Error\n" , __func__);if (ctrl->eccread) { -int bufperpage = mtd->writesize /512 ; -int bufnum = (ctrl->page & priv->bufnum_mask) * bufperpage; -int bufnum_end = bufnum + bufperpage -1 ; +int errors; +int bufnum = ctrl->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, ctrl, bufnum)) + ctrl->status |= +IFC_NAND_EVTER_STAT_ECCER ;break ; + } + + mtd->ecc_stats.corrected += errors; } ctrl->eccread =0 ;
Signature · 1 line
1.7.5.4
PATCH 1/1 mtd/nand:Fix wrong usage of is_blank() in fsl_ifc_run_command
Quoted 17 lines · 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 tois_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 <[email protected]>Signed-off-by Scott Wood <[email protected]>Signed-off-by Prabhakar Kushwaha <[email protected]>---
Applied upongit://git.denx.de/u-boot.git(branch master)This patch is based upon ifc driver patch in linuxppc-dev mailing list
http://patchwork.ozlabs.org/patch/136547/
Quoted 7 lines
It is a replacement of my earlier patch
"mtd/nand:Fix wrong address read inis_blank()"
http://patchwork.ozlabs.org/patch/133388/drivers/mtd/nand/fsl_ifc_nand.c | 52 +++++++++++++++++++++------------------ 1 files changed, 28 insertions(+), 24 deletions(-)
Applied to u-boot-nand-flash...
drivers/mtd/nand/fsl_ifc_nand.c static int fsl_ifc_run_command(struct mtd_info *mtd) · line 288
Quoted 8 lines
drivers/mtd/nand/fsl_ifc_nand.c +8
-0+/* +* 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. +*/
...with the "..." removed from the comment.
-Scott