summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorStefan Agner <stefan.agner@toradex.com>2016-10-26 17:18:44 -0700
committerMax Krummenacher <max.krummenacher@toradex.com>2017-01-11 15:42:35 +0100
commitff58aaf0bb23129c81099c3b2ea89954022bf6cf (patch)
tree4f250906adccf156bf1cbeb0389deaa20f2c51a1 /drivers
parente2ee1afc28a13a0894fd2db0a5ae7a2262fdd1c0 (diff)
nand: force BBT scan for controllers which need it
Commit 35c204d8a9d0 ("nand: reinstate lazy bad block scanning") introduced lazy BBT scanning. However, some controller do parts of the initialization (mxs_nand.c) during scan_bbt, hence for those controllers the BBT must be scanned at initialization time. In most situation the U-Boot environment gets read first, and the U-Boot environment code checks for bad blocks first. Checking for bad blocks will ask for scan_bbt before reading the first page, hence in most situation the issue does not appear in practice. However, when there is no environment configured, other code might access NAND first which does not explicitly checks for bad blocks, in those cases ECC reads will fail always. Cc: Rostislav Lisovy <lisovy@gmail.com> Signed-off-by: Stefan Agner <stefan.agner@toradex.com> Acked-by: Max Krummenacher <max.krummenacher@toradex.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/nand/mxs_nand.c2
-rw-r--r--drivers/mtd/nand/nand_base.c5
2 files changed, 6 insertions, 1 deletions
diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c
index 92005448d2..d3c420afde 100644
--- a/drivers/mtd/nand/mxs_nand.c
+++ b/drivers/mtd/nand/mxs_nand.c
@@ -1181,7 +1181,7 @@ int board_nand_init(struct nand_chip *nand)
memset(&fake_ecc_layout, 0, sizeof(fake_ecc_layout));
nand_set_controller_data(nand, nand_info);
- nand->options |= NAND_NO_SUBPAGE_WRITE;
+ nand->options |= NAND_NO_SUBPAGE_WRITE | NAND_NEED_BBTSCAN;
nand->cmd_ctrl = mxs_nand_cmd_ctrl;
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index d9e5fc95f5..9d1ab57e20 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -4216,6 +4216,11 @@ int nand_scan_tail(struct mtd_info *mtd)
if (!mtd->bitflip_threshold)
mtd->bitflip_threshold = DIV_ROUND_UP(mtd->ecc_strength * 3, 4);
+ if (chip->options & NAND_NEED_BBTSCAN) {
+ chip->options |= NAND_BBT_SCANNED;
+ return chip->scan_bbt(mtd);
+ }
+
return 0;
}
EXPORT_SYMBOL(nand_scan_tail);