* [PATCH] UBI:Force ubi driver load after mtd device drivers
@ 2012-08-08 2:31 Jiang Lu
2012-08-08 21:52 ` richard -rw- weinberger
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Jiang Lu @ 2012-08-08 2:31 UTC (permalink / raw)
To: linux-mtd
To implement rootfs on mtd device with UBIFS, kernel need create a
UBIFS device when booting:
drivers/mtd/ubi/build.c ubi_init()
for (i = 0; i < mtd_devs; i++) {
...
mtd = open_mtd_device(p->name);
if (IS_ERR(mtd)) {
err = PTR_ERR(mtd);
goto out_detach;
}
ubi_attach_mtd_dev()
...
}
module_init(ubi_init);
Kernel can not create the UBIFS device without corresponding mtd
partiton.
Some NAND device can not guarenteen the mtd patition created before
UBIFS deivce driver loading. Such as SPI NAND deivce, the mtd partition
will create after SPI bus driver loaded.
UBI device driver must load after other mtd device drivers to make sure
the mtd partition already exist when creating UBI deivce.
The patch updates the UBI device driver's initial routine to
late_initcall level.
Signed-off-by: Jiang Lu <lu.jiang@windriver.com>
---
drivers/mtd/ubi/build.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 0fde9fc..efbcaef 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -1275,7 +1275,7 @@ out:
ubi_err("UBI error: cannot initialize UBI, error %d", err);
return err;
}
-module_init(ubi_init);
+late_initcall(ubi_init);
static void __exit ubi_exit(void)
{
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] UBI:Force ubi driver load after mtd device drivers
2012-08-08 2:31 [PATCH] UBI:Force ubi driver load after mtd device drivers Jiang Lu
@ 2012-08-08 21:52 ` richard -rw- weinberger
2012-08-09 5:46 ` Warrick
2012-08-24 9:41 ` Artem Bityutskiy
2012-08-28 13:52 ` Artem Bityutskiy
2 siblings, 1 reply; 8+ messages in thread
From: richard -rw- weinberger @ 2012-08-08 21:52 UTC (permalink / raw)
To: Jiang Lu; +Cc: linux-mtd
On Wed, Aug 8, 2012 at 4:31 AM, Jiang Lu <lu.jiang@windriver.com> wrote:
> To implement rootfs on mtd device with UBIFS, kernel need create a
> UBIFS device when booting:
>
> drivers/mtd/ubi/build.c ubi_init()
> for (i = 0; i < mtd_devs; i++) {
> ...
> mtd = open_mtd_device(p->name);
> if (IS_ERR(mtd)) {
> err = PTR_ERR(mtd);
> goto out_detach;
> }
>
> ubi_attach_mtd_dev()
> ...
> }
> module_init(ubi_init);
>
> Kernel can not create the UBIFS device without corresponding mtd
> partiton.
>
> Some NAND device can not guarenteen the mtd patition created before
> UBIFS deivce driver loading. Such as SPI NAND deivce, the mtd partition
> will create after SPI bus driver loaded.
>
> UBI device driver must load after other mtd device drivers to make sure
> the mtd partition already exist when creating UBI deivce.
>
> The patch updates the UBI device driver's initial routine to
> late_initcall level.
>
> Signed-off-by: Jiang Lu <lu.jiang@windriver.com>
> ---
> drivers/mtd/ubi/build.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> index 0fde9fc..efbcaef 100644
> --- a/drivers/mtd/ubi/build.c
> +++ b/drivers/mtd/ubi/build.c
> @@ -1275,7 +1275,7 @@ out:
> ubi_err("UBI error: cannot initialize UBI, error %d", err);
> return err;
> }
> -module_init(ubi_init);
> +late_initcall(ubi_init);
Cant we use a simple initrd in such a case?
Within the initrd you can load the ubi module after your SPI NAND is done.
--
Thanks,
//richard
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] UBI:Force ubi driver load after mtd device drivers
2012-08-08 21:52 ` richard -rw- weinberger
@ 2012-08-09 5:46 ` Warrick
0 siblings, 0 replies; 8+ messages in thread
From: Warrick @ 2012-08-09 5:46 UTC (permalink / raw)
To: richard -rw- weinberger; +Cc: linux-mtd, Jiang Lu
于 2012年08月09日 05:52, richard -rw- weinberger 写道:
> On Wed, Aug 8, 2012 at 4:31 AM, Jiang Lu <lu.jiang@windriver.com> wrote:
>> To implement rootfs on mtd device with UBIFS, kernel need create a
>> UBIFS device when booting:
>>
>> drivers/mtd/ubi/build.c ubi_init()
>> for (i = 0; i < mtd_devs; i++) {
>> ...
>> mtd = open_mtd_device(p->name);
>> if (IS_ERR(mtd)) {
>> err = PTR_ERR(mtd);
>> goto out_detach;
>> }
>>
>> ubi_attach_mtd_dev()
>> ...
>> }
>> module_init(ubi_init);
>>
>> Kernel can not create the UBIFS device without corresponding mtd
>> partiton.
>>
>> Some NAND device can not guarenteen the mtd patition created before
>> UBIFS deivce driver loading. Such as SPI NAND deivce, the mtd partition
>> will create after SPI bus driver loaded.
>>
>> UBI device driver must load after other mtd device drivers to make sure
>> the mtd partition already exist when creating UBI deivce.
>>
>> The patch updates the UBI device driver's initial routine to
>> late_initcall level.
>>
>> Signed-off-by: Jiang Lu <lu.jiang@windriver.com>
>> ---
>> drivers/mtd/ubi/build.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
>> index 0fde9fc..efbcaef 100644
>> --- a/drivers/mtd/ubi/build.c
>> +++ b/drivers/mtd/ubi/build.c
>> @@ -1275,7 +1275,7 @@ out:
>> ubi_err("UBI error: cannot initialize UBI, error %d", err);
>> return err;
>> }
>> -module_init(ubi_init);
>> +late_initcall(ubi_init);
> Cant we use a simple initrd in such a case?
> Within the initrd you can load the ubi module after your SPI NAND is done.
>
This could be a workround. But for the ubi device driver, kernel should
invoke ubi_init() after all mtd partition ready.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] UBI:Force ubi driver load after mtd device drivers
2012-08-08 2:31 [PATCH] UBI:Force ubi driver load after mtd device drivers Jiang Lu
2012-08-08 21:52 ` richard -rw- weinberger
@ 2012-08-24 9:41 ` Artem Bityutskiy
2012-08-24 10:03 ` Artem Bityutskiy
2012-08-24 11:24 ` Artem Bityutskiy
2012-08-28 13:52 ` Artem Bityutskiy
2 siblings, 2 replies; 8+ messages in thread
From: Artem Bityutskiy @ 2012-08-24 9:41 UTC (permalink / raw)
To: Jiang Lu; +Cc: linux-mtd
[-- Attachment #1: Type: text/plain, Size: 608 bytes --]
On Wed, 2012-08-08 at 10:31 +0800, Jiang Lu wrote:
> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> index 0fde9fc..efbcaef 100644
> --- a/drivers/mtd/ubi/build.c
> +++ b/drivers/mtd/ubi/build.c
> @@ -1275,7 +1275,7 @@ out:
> ubi_err("UBI error: cannot initialize UBI, error %d", err);
> return err;
> }
> -module_init(ubi_init);
> +late_initcall(ubi_init);
The problem is that UBIFS, which is usually used on top of UBI, also
uses 'late_initcall()'. If we do this change, how do we guarantee that
UBIFS is initialized after UBI?
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] UBI:Force ubi driver load after mtd device drivers
2012-08-24 9:41 ` Artem Bityutskiy
@ 2012-08-24 10:03 ` Artem Bityutskiy
2012-08-24 11:24 ` Artem Bityutskiy
1 sibling, 0 replies; 8+ messages in thread
From: Artem Bityutskiy @ 2012-08-24 10:03 UTC (permalink / raw)
To: Jiang Lu; +Cc: linux-mtd
[-- Attachment #1: Type: text/plain, Size: 1007 bytes --]
On Fri, 2012-08-24 at 12:41 +0300, Artem Bityutskiy wrote:
> On Wed, 2012-08-08 at 10:31 +0800, Jiang Lu wrote:
> > diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> > index 0fde9fc..efbcaef 100644
> > --- a/drivers/mtd/ubi/build.c
> > +++ b/drivers/mtd/ubi/build.c
> > @@ -1275,7 +1275,7 @@ out:
> > ubi_err("UBI error: cannot initialize UBI, error %d", err);
> > return err;
> > }
> > -module_init(ubi_init);
> > +late_initcall(ubi_init);
>
> The problem is that UBIFS, which is usually used on top of UBI, also
> uses 'late_initcall()'. If we do this change, how do we guarantee that
> UBIFS is initialized after UBI?
It looks like the right way to fix the issue is to change the way UBI
initializes. We should not try to open the MTD device, scan it and
attach in the initcall. We should instead delay this till the first
open. So when you open the device for the firs time, you actually end up
with the scanning, etc.
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] UBI:Force ubi driver load after mtd device drivers
2012-08-24 9:41 ` Artem Bityutskiy
2012-08-24 10:03 ` Artem Bityutskiy
@ 2012-08-24 11:24 ` Artem Bityutskiy
2012-08-27 1:10 ` Lu.Jiang
1 sibling, 1 reply; 8+ messages in thread
From: Artem Bityutskiy @ 2012-08-24 11:24 UTC (permalink / raw)
To: Jiang Lu; +Cc: linux-mtd
[-- Attachment #1: Type: text/plain, Size: 836 bytes --]
On Fri, 2012-08-24 at 12:41 +0300, Artem Bityutskiy wrote:
> On Wed, 2012-08-08 at 10:31 +0800, Jiang Lu wrote:
> > diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> > index 0fde9fc..efbcaef 100644
> > --- a/drivers/mtd/ubi/build.c
> > +++ b/drivers/mtd/ubi/build.c
> > @@ -1275,7 +1275,7 @@ out:
> > ubi_err("UBI error: cannot initialize UBI, error %d", err);
> > return err;
> > }
> > -module_init(ubi_init);
> > +late_initcall(ubi_init);
>
> The problem is that UBIFS, which is usually used on top of UBI, also
> uses 'late_initcall()'. If we do this change, how do we guarantee that
> UBIFS is initialized after UBI?
Although, I think it is not really a problem and UBIFS can be
initialized at any point - it does not depend on UBI being initialized.
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] UBI:Force ubi driver load after mtd device drivers
2012-08-24 11:24 ` Artem Bityutskiy
@ 2012-08-27 1:10 ` Lu.Jiang
0 siblings, 0 replies; 8+ messages in thread
From: Lu.Jiang @ 2012-08-27 1:10 UTC (permalink / raw)
To: dedekind1; +Cc: linux-mtd
于 2012年08月24日 19:24, Artem Bityutskiy 写道:
> On Fri, 2012-08-24 at 12:41 +0300, Artem Bityutskiy wrote:
>> On Wed, 2012-08-08 at 10:31 +0800, Jiang Lu wrote:
>>> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
>>> index 0fde9fc..efbcaef 100644
>>> --- a/drivers/mtd/ubi/build.c
>>> +++ b/drivers/mtd/ubi/build.c
>>> @@ -1275,7 +1275,7 @@ out:
>>> ubi_err("UBI error: cannot initialize UBI, error %d", err);
>>> return err;
>>> }
>>> -module_init(ubi_init);
>>> +late_initcall(ubi_init);
>> The problem is that UBIFS, which is usually used on top of UBI, also
>> uses 'late_initcall()'. If we do this change, how do we guarantee that
>> UBIFS is initialized after UBI?
> Although, I think it is not really a problem and UBIFS can be
> initialized at any point - it does not depend on UBI being initialized.
>
Yes, it works fine with this change. UFIFS can be mount as rootfs device
on SPI flash after ubi_init() change to late_initcall().
Jiang Lu
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] UBI:Force ubi driver load after mtd device drivers
2012-08-08 2:31 [PATCH] UBI:Force ubi driver load after mtd device drivers Jiang Lu
2012-08-08 21:52 ` richard -rw- weinberger
2012-08-24 9:41 ` Artem Bityutskiy
@ 2012-08-28 13:52 ` Artem Bityutskiy
2 siblings, 0 replies; 8+ messages in thread
From: Artem Bityutskiy @ 2012-08-28 13:52 UTC (permalink / raw)
To: Jiang Lu; +Cc: linux-mtd
[-- Attachment #1: Type: text/plain, Size: 228 bytes --]
On Wed, 2012-08-08 at 10:31 +0800, Jiang Lu wrote:
> To implement rootfs on mtd device with UBIFS, kernel need create a
> UBIFS device when booting:
Pushed to linux-ubi.git, thanks!
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-08-28 13:47 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-08 2:31 [PATCH] UBI:Force ubi driver load after mtd device drivers Jiang Lu
2012-08-08 21:52 ` richard -rw- weinberger
2012-08-09 5:46 ` Warrick
2012-08-24 9:41 ` Artem Bityutskiy
2012-08-24 10:03 ` Artem Bityutskiy
2012-08-24 11:24 ` Artem Bityutskiy
2012-08-27 1:10 ` Lu.Jiang
2012-08-28 13:52 ` Artem Bityutskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).