* [U-Boot] [PATCH] nand: force BBT scan for controllers which need it
@ 2016-10-27 0:18 Stefan Agner
2016-11-15 5:30 ` Scott Wood
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Agner @ 2016-10-27 0:18 UTC (permalink / raw)
To: u-boot
From: Stefan Agner <stefan.agner@toradex.com>
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>
---
Not sure if this solution is a nice solution as we diverge more
and more from the kernel...
drivers/mtd/nand/mxs_nand.c | 2 +-
drivers/mtd/nand/nand_base.c | 5 +++++
include/linux/mtd/nand.h | 2 ++
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c
index 9200544..d3c420a 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 d9e5fc9..9d1ab57 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);
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index d55807b..d939896 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -224,6 +224,8 @@ typedef enum {
* kmap'ed, vmalloc'ed highmem buffers being passed from upper layers
*/
#define NAND_USE_BOUNCE_BUFFER 0x00100000
+/* Chip needs BBT scan */
+#define NAND_NEED_BBTSCAN 0x00200000
/* Options set by nand scan */
/* bbt has already been read */
--
2.10.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] nand: force BBT scan for controllers which need it
2016-10-27 0:18 [U-Boot] [PATCH] nand: force BBT scan for controllers which need it Stefan Agner
@ 2016-11-15 5:30 ` Scott Wood
2016-11-15 18:43 ` Stefan Agner
0 siblings, 1 reply; 3+ messages in thread
From: Scott Wood @ 2016-11-15 5:30 UTC (permalink / raw)
To: u-boot
On Wed, 2016-10-26 at 17:18 -0700, Stefan Agner wrote:
> From: Stefan Agner <stefan.agner@toradex.com>
>
> 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>
> ---
> Not sure if this solution is a nice solution as we diverge more
> and more from the kernel...
Why does this init code need to run at the end of nand_scan_tail()? ?If it can
run in between nand_scan_ident() and nand_scan_tail(), then use
CONFIG_SYS_NAND_SELF_INIT to allow the driver to run its init at that time.
-Scott
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] nand: force BBT scan for controllers which need it
2016-11-15 5:30 ` Scott Wood
@ 2016-11-15 18:43 ` Stefan Agner
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Agner @ 2016-11-15 18:43 UTC (permalink / raw)
To: u-boot
On 2016-11-14 21:30, Scott Wood wrote:
> On Wed, 2016-10-26 at 17:18 -0700, Stefan Agner wrote:
>> From: Stefan Agner <stefan.agner@toradex.com>
>>
>> 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>
>> ---
>> Not sure if this solution is a nice solution as we diverge more
>> and more from the kernel...
>
> Why does this init code need to run at the end of nand_scan_tail()? ?If it can
> run in between nand_scan_ident() and nand_scan_tail(), then use
> CONFIG_SYS_NAND_SELF_INIT to allow the driver to run its init at that time.
Hm, the comment in mxs_nand.c claims that we don't have formal mechanism
for this, but that has been written in 2011 and
CONFIG_SYS_NAND_SELF_INIT has been added in 2012, hence I guess we could
get rid of that hack.
Will check if your suggestion...
--
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-11-15 18:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-27 0:18 [U-Boot] [PATCH] nand: force BBT scan for controllers which need it Stefan Agner
2016-11-15 5:30 ` Scott Wood
2016-11-15 18:43 ` Stefan Agner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox