public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] mtd, ubi: set free_count to zero before walking through erase list
@ 2016-02-02 10:54 Heiko Schocher
  2016-02-02 11:40 ` Richard Weinberger
  2016-04-21  8:58 ` Boris Brezillon
  0 siblings, 2 replies; 15+ messages in thread
From: Heiko Schocher @ 2016-02-02 10:54 UTC (permalink / raw)
  To: u-boot

Set free_count to zero before walking through ai->erase list
in wl_init().

As U-Boot has no workqueue/threads, it immediately calls
erase_worker(), which increase for each erased block
free_count. Without this patch, free_count gets after
this initialized to zero in wl_init(), so the free_count
variable always has the maybe wrong value 0.

Detected this behaviour on the dxr2 board, where the
UBI fastmap gets not written when attaching/dettaching
on an empty NAND. It drops instead the error message:

could not find any anchor PEB

With this patch, fastmap gets written on dettach.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
added Richard to this EMail, as maybe this could be a problem
in linux too ... ?

 drivers/mtd/ubi/wl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 507b091..e823ca5 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -1528,6 +1528,7 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai)
 		INIT_LIST_HEAD(&ubi->pq[i]);
 	ubi->pq_head = 0;
 
+	ubi->free_count = 0;
 	list_for_each_entry_safe(aeb, tmp, &ai->erase, u.list) {
 		cond_resched();
 
@@ -1546,7 +1547,6 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai)
 		found_pebs++;
 	}
 
-	ubi->free_count = 0;
 	list_for_each_entry(aeb, &ai->free, u.list) {
 		cond_resched();
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2016-04-25  7:06 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-02 10:54 [U-Boot] [PATCH] mtd, ubi: set free_count to zero before walking through erase list Heiko Schocher
2016-02-02 11:40 ` Richard Weinberger
2016-02-02 12:53   ` Heiko Schocher
2016-04-21  8:58 ` Boris Brezillon
2016-04-21 10:09   ` Heiko Schocher
2016-04-21 10:25     ` Boris Brezillon
2016-04-21 10:48       ` Heiko Schocher
2016-04-21 12:14         ` Boris Brezillon
2016-04-22  9:34           ` Richard Weinberger
2016-04-22 10:20             ` Heiko Schocher
2016-04-22 10:48               ` Richard Weinberger
2016-04-22 11:53                 ` Heiko Schocher
2016-04-22 12:21                   ` Boris Brezillon
2016-04-25  5:46                     ` Heiko Schocher
2016-04-25  7:06                       ` Richard Weinberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox