2023-07-12 14:26:02

by Pintu Kumar

[permalink] [raw]
Subject: MTD: Lots of mtdblock warnings on bootup logs

Hi,

We are getting below warning messages in dmesg logs on a NAND device
for every raw partition.
Kernel: 5.15 ; arm64 ; NAND + ubi + squashfs
We have some RAW partitions and one UBI partition (with ubifs/squashfs volumes).

We are seeing large numbers of these logs on the serial console that
impact the boot time.
[....]
[ 9.667240][ T9] Creating 58 MTD partitions on "1c98000.nand":
[....]
[ 39.975707][ T519] mtdblock: MTD device 'uefi_a' is NAND, please
consider using UBI block devices instead.
[ 39.975707][ T519] mtdblock: MTD device 'uefi_b' is NAND, please
consider using UBI block devices instead.
[....]

This was added as part of this commit:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/drivers/mtd/mtdblock.c?h=v5.15.120&id=f41c9418c5898c01634675150696da290fb86796
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/drivers/mtd/mtdblock.c?h=v5.15.120&id=e07403a8c6be01857ff75060b2df9a1aa8320fe5

I think this warning was decided after my last year's discussion about
mtdblock vs ubiblock for squashfs.

But these are raw NAND partitions and not mounted by us.

What is the exact meaning of these warnings ?

We have both these configs enabled:
CONFIG_MTD_BLOCK=y
CONFIG_MTD_UBI_BLOCK=y

Through this warning, are we telling that only one of the above config
should be enabled ?
And the recommendation is to use ubi_block and disable mtd_block ?

We are already using ubiblock for mounting squashfs volumes.
But how to get rid of these warnings for raw NAND partitions ?

Is there a way to avoid or we are missing something which we are not aware of?


Thanks,
Pintu


2023-07-12 14:28:57

by Miquel Raynal

[permalink] [raw]
Subject: Re: MTD: Lots of mtdblock warnings on bootup logs

Hi Pintu,

[email protected] wrote on Wed, 12 Jul 2023 19:29:39 +0530:

> Hi,
>
> We are getting below warning messages in dmesg logs on a NAND device
> for every raw partition.
> Kernel: 5.15 ; arm64 ; NAND + ubi + squashfs
> We have some RAW partitions and one UBI partition (with ubifs/squashfs volumes).
>
> We are seeing large numbers of these logs on the serial console that
> impact the boot time.
> [....]
> [ 9.667240][ T9] Creating 58 MTD partitions on "1c98000.nand":
> [....]
> [ 39.975707][ T519] mtdblock: MTD device 'uefi_a' is NAND, please
> consider using UBI block devices instead.
> [ 39.975707][ T519] mtdblock: MTD device 'uefi_b' is NAND, please
> consider using UBI block devices instead.
> [....]
>
> This was added as part of this commit:
> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/drivers/mtd/mtdblock.c?h=v5.15.120&id=f41c9418c5898c01634675150696da290fb86796
> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/drivers/mtd/mtdblock.c?h=v5.15.120&id=e07403a8c6be01857ff75060b2df9a1aa8320fe5
>
> I think this warning was decided after my last year's discussion about
> mtdblock vs ubiblock for squashfs.
>
> But these are raw NAND partitions and not mounted by us.
>
> What is the exact meaning of these warnings ?

mtdblock is legacy, ubiblock is better (on NAND devices).

> We have both these configs enabled:
> CONFIG_MTD_BLOCK=y
> CONFIG_MTD_UBI_BLOCK=y
>
> Through this warning, are we telling that only one of the above config
> should be enabled ?

If you don't need both, then yes.

> And the recommendation is to use ubi_block and disable mtd_block ?

Yes.

> We are already using ubiblock for mounting squashfs volumes.
> But how to get rid of these warnings for raw NAND partitions ?
>
> Is there a way to avoid or we are missing something which we are not aware of?
>

In theory the warning should only appear if you open the device (IOW,
only if you use it). For this to happen, you need:
96a3295c351d ("mtdblock: warn if opened on NAND")
This commit was maybe not backported to stable kernels, you can send it
to [email protected] in order to ask for that. I also see that the
mtdblock_ro path was not corrected, maybe that's also a problem in your
case? Same, you can adapt the above patch and send it upstream.

Thanks,
Miquèl

2023-07-12 15:16:48

by Bjørn Mork

[permalink] [raw]
Subject: Re: MTD: Lots of mtdblock warnings on bootup logs

Pintu Agarwal <[email protected]> writes:

> Kernel: 5.15 ; arm64 ; NAND + ubi + squashfs
> We have some RAW partitions and one UBI partition (with ubifs/squashfs volumes).
>
> We are seeing large numbers of these logs on the serial console that
> impact the boot time.
> [....]
> [ 9.667240][ T9] Creating 58 MTD partitions on "1c98000.nand":
> [....]
> [ 39.975707][ T519] mtdblock: MTD device 'uefi_a' is NAND, please
> consider using UBI block devices instead.
> [ 39.975707][ T519] mtdblock: MTD device 'uefi_b' is NAND, please
> consider using UBI block devices instead.
> [....]
>
> This was added as part of this commit:
> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/drivers/mtd/mtdblock.c?h=v5.15.120&id=f41c9418c5898c01634675150696da290fb86796
> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/drivers/mtd/mtdblock.c?h=v5.15.120&id=e07403a8c6be01857ff75060b2df9a1aa8320fe5

You have 5.15.what exactly? commit f41c9418c5898 was added in v5.15.46.
Your log looks like it is missing.

FWIW, commit f41c9418c5898 was supposed to fix exactly that problem with
commit e07403a8c6be01.

But to catch actual mounts it will still warn if the mtdblock device is
opened. This can obviously cause false positives if you e.g have some
script reading from the mtdblock devices. If you are running v5.15.46 or
later then there *is* something accessing those devices. You'll have to
figure out what it is and stop it to avoid the warning.


Bjørn

2023-07-12 18:57:08

by Pintu Kumar

[permalink] [raw]
Subject: Re: MTD: Lots of mtdblock warnings on bootup logs

Dear Bjorn and Miquel,

Thank you so much for your help!
Please see my reply inline.

On Wed, 12 Jul 2023 at 19:58, Bjørn Mork <[email protected]> wrote:
>
> Pintu Agarwal <[email protected]> writes:
>
> > Kernel: 5.15 ; arm64 ; NAND + ubi + squashfs
> > We have some RAW partitions and one UBI partition (with ubifs/squashfs volumes).
> >
> > We are seeing large numbers of these logs on the serial console that
> > impact the boot time.
> > [....]
> > [ 9.667240][ T9] Creating 58 MTD partitions on "1c98000.nand":
> > [....]
> > [ 39.975707][ T519] mtdblock: MTD device 'uefi_a' is NAND, please
> > consider using UBI block devices instead.
> > [ 39.975707][ T519] mtdblock: MTD device 'uefi_b' is NAND, please
> > consider using UBI block devices instead.
> > [....]
> >
> > This was added as part of this commit:
> > https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/drivers/mtd/mtdblock.c?h=v5.15.120&id=f41c9418c5898c01634675150696da290fb86796
> > https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/drivers/mtd/mtdblock.c?h=v5.15.120&id=e07403a8c6be01857ff75060b2df9a1aa8320fe5
>
> You have 5.15.what exactly? commit f41c9418c5898 was added in v5.15.46.
> Your log looks like it is missing.
>
My exact Kernel version is: 5.15.78
And I see that the below commit is also present:
commit f41c9418c5898c01634675150696da290fb86796
mtdblock: warn if opened on NAND

> FWIW, commit f41c9418c5898 was supposed to fix exactly that problem with
> commit e07403a8c6be01.
>
> But to catch actual mounts it will still warn if the mtdblock device is
> opened. This can obviously cause false positives if you e.g have some
> script reading from the mtdblock devices. If you are running v5.15.46 or
> later then there *is* something accessing those devices. You'll have to
> figure out what it is and stop it to avoid the warning.
>
You mean, if someone is using "mount .. /dev/mtdblock*" then only we
get these warnings ?
Or, if someone is trying to access the node using open("/dev/mtdblock*") .

But in this case, there should be only 1,2,3 entries but here I am
seeing for all the NAND partitions.
Or, is it possible that systemd-udevd is trying to access these nodes ?

Can we use ubiblock for mount ubifs (rw) volumes, or here we have to
use mtdblock ?
We have a mixture of squashfs (ro) and ubifs (rw) ubi volumes.
Currently, we are using the ubiblock way of mounting for squashfs but
mtdblock mounting for ubifs.

>> CONFIG_MTD_BLOCK=y
>> CONFIG_MTD_UBI_BLOCK=y
>>
> If you don't need both, then yes.

We actually need both of them because of several dependencies.

There are few applications that are trying to read content from /proc/mtd.
Is this also a problem if we disable MTD_BLOCK ?


Thanks,
Pintu

2023-07-12 20:10:51

by Bjørn Mork

[permalink] [raw]
Subject: Re: MTD: Lots of mtdblock warnings on bootup logs

Pintu Agarwal <[email protected]> writes:

> You mean, if someone is using "mount .. /dev/mtdblock*" then only we
> get these warnings ?
> Or, if someone is trying to access the node using open("/dev/mtdblock*") .

open() will cause a warning.

> But in this case, there should be only 1,2,3 entries but here I am
> seeing for all the NAND partitions.
> Or, is it possible that systemd-udevd is trying to access these nodes ?

Maybe? Something trying to figure out the contents of all block devices
perhaps?

> Can we use ubiblock for mount ubifs (rw) volumes, or here we have to
> use mtdblock ?
> We have a mixture of squashfs (ro) and ubifs (rw) ubi volumes.
> Currently, we are using the ubiblock way of mounting for squashfs but
> mtdblock mounting for ubifs.

I don't think it's safe to use mtdblock on NAND. WHich is what the
warning is about.


Bjørn