public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
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: Fri, 22 Apr 2016 12:20:22 +0200	[thread overview]
Message-ID: <5719FAE6.2010603@denx.de> (raw)
In-Reply-To: <5719F01A.7090400@nod.at>

Hello Richard,

Am 22.04.2016 um 11:34 schrieb Richard Weinberger:
> Am 21.04.2016 um 14:14 schrieb Boris Brezillon:
>>>>> 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 ...
>>>>
>>>> I discussed that with Richard, and I think moving the ->free_count
>>>> assignment before iterating over the ->erase list is a good solution.
>>>
>>> Ah! Ok, than its fine for me too.
>>>
>>>> I know the Linux code is assuming that the UBI thread is not launched
>>>> yet when we call ubi_wl_init(), but to me it seems a bit risky to rely
>>>> on this assumption (what if we do the UBI thread creation a bit
>>>> earlier for some reason?). And, of course, as you explained, uboot does
>>>> not know anything about threads, so all UBI works are executed
>>>> synchronously, which makes this implementation buggy in uboot.
>>>
>>> Hmm... is it also a valid fix for linux then?
>>
>> Well, it's not required, but it's making the code more future proof
>> IMO. So again, I'll let Richard decide on this aspect.
>
> As discussed with Boris, I'm not a huge fan of the said patch but I
> understand the need for it.
> Please send it to linux-mtd I'll apply it.

Ok, done.

> That said, the root cause of the whole issue is that due to the
> single thread nature of u-boot UBI work is directly executed
> at schedule time. For u-boot this works more or less.
> But UBI allows work being scheduled when the background thread is
> disabled/paused or not spawned.
> The free_count patch papers exactly over one of these cases.
> Let's hope that there are not other (more nasty) cases where
> u-boot and Linux UBI behave differently.

:-(

> Think of places where work is scheduled but the caller blocked
> the worker because the work has to be done later.
> Fastmap is one of these use cases but AFAIK it won't matter
> as no CPU scheduler is involved and will interrupt Fastmap.

Can you explain this a little bit?

> Boris and I worked the last months on a bigger UBI project
> where we also had to port our UBI changes to u-boot.
> Now I'm not so sure anymore whether it is a good idea to
> copy&paste UBI from Linux to u-boot. We faced a lot of
> issues due to the single thread model. I changed the work
> model in UBI to make locking less complicated. It turned out
> that on u-boot it made things more complicated.
> At least Boris had a lot of "fun". ;-)

Heh...

> In the long run I suggest removing the whole Linux UBI implementation
> from u-boot and add a small (read only!) implementation which can
> also read UBIFS. Reading UBIFS is not a big deal. Also journal reply
> can be done in-memory.

Hmm.. I think read only is not for all boards an option, as we also
create UBI Volumes and/or write to them in U-Boot ...

> Beside of code complexity it will also reduce u-boot's .text size.
> Thomas' SPL patches are a very good start.

Yes, I hope to get soon an Ack/Response from Ladislav and/or Enric,
so we can integrate them into mainline.

> I'd also offer my help.

Thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

  reply	other threads:[~2016-04-22 10:20 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
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 [this message]
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=5719FAE6.2010603@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