mtd: nand: fix false ecc report on infopage
authorYonghui Yu <yonghui.yu@amlogic.com>
Thu, 20 Jul 2017 14:38:16 +0000 (22:38 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Thu, 3 Aug 2017 06:15:41 +0000 (23:15 -0700)
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 <yonghui.yu@amlogic.com>
drivers/amlogic/mtd/boot.c

index 4f393c0..1bd97ae 100644 (file)
@@ -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;