From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] mtd, ubi: set free_count to zero before walking through erase list
Date: Thu, 21 Apr 2016 12:09:34 +0200 [thread overview]
Message-ID: <5718A6DE.6040109@denx.de> (raw)
In-Reply-To: <20160421105846.696b0eff@bbrezillon>
Hello Boris,
Am 21.04.2016 um 10:58 schrieb Boris Brezillon:
> On Tue, 2 Feb 2016 11:54:35 +0100
> Heiko Schocher <hs@denx.de> wrote:
>
>> 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.
>
> I ran into the same problem, and produced the exact same patch to
> fix it, so
>
> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Thanks!
I did not yet found time, to investigate this problem deeper,
sorry.
The real reason to me seems, on an empty nand flash, we call
scan_all() which calls scan_peb() which calls ubi_io_read_ec_hdr()
which returns UBI_IO_FF as the nand is empty.
This adds the PEB to the erase list, and here comes the difference
between U-Boot and linux, we have no threads in U-Boot, so we call
the erase_worker function immediately ... which increments the
"ubi->free_count" variable ... after that it get set to
"ubi->free_count = 0" ... which leads into the error we see ...
No idea, if the correct fix not would be to move this erase_worker
call after the attach phase ended, as Richard suggested, or if this
fix is also valid ...
Do you have some time to check such a fix as Richard suggested?
bye,
Heiko
>
>>
>> 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();
>>
>
>
>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
next prev parent reply other threads:[~2016-04-21 10:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5718A6DE.6040109@denx.de \
--to=hs@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox