From b5e6195c5eb76209084a56e6d903022601f09151 Mon Sep 17 00:00:00 2001 From: Yonghui Yu Date: Thu, 20 Jul 2017 22:38:16 +0800 Subject: [PATCH] mtd: nand: fix false ecc report on infopage MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit PD#147956: mtd: nand: fix false ecc report on infopage Infopage must be programed with scrambled to fit romboot. And all “0xff” page will be reported as uncorrectable falsely with scramber on. we have to exclude this by counting the zero byts. Change-Id: I167491bee69444f64231a09e41d04bcd03f30d65 Signed-off-by: Yonghui Yu --- drivers/amlogic/mtd/boot.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/amlogic/mtd/boot.c b/drivers/amlogic/mtd/boot.c index 4f393c0..1bd97ae 100644 --- a/drivers/amlogic/mtd/boot.c +++ b/drivers/amlogic/mtd/boot.c @@ -279,8 +279,7 @@ int m3_nand_boot_read_page_hwecc(struct mtd_info *mtd, } error = aml_chip->aml_nand_dma_read(aml_chip, buf, nand_page_size, bch_mode); - if (en_slc == 0) - aml_chip->ran_mode = ran_mode; + if (error) pr_info(" page0 aml_nand_dma_read failed\n"); @@ -289,10 +288,18 @@ int m3_nand_boot_read_page_hwecc(struct mtd_info *mtd, stat = aml_chip->aml_nand_hwecc_correct(aml_chip, buf, nand_page_size, oob_buf); if (stat < 0) { - mtd->ecc_stats.failed++; - pr_info("page0 read ecc fail at blk0 chip0\n"); + if(aml_chip->ran_mode + && (aml_chip->zero_cnt < aml_chip->ecc_max)) { + memset(buf, 0xff, nand_page_size); + memset(oob_buf, 0xff, user_byte_num); + } else { + mtd->ecc_stats.failed++; + pr_info("page0 read ecc fail at blk0 chip0\n"); + } } else mtd->ecc_stats.corrected += stat; + if (en_slc == 0) + aml_chip->ran_mode = ran_mode; } else { pr_info("nand boot page 0 no valid chip failed\n"); error = -ENODEV; -- 2.7.4