diff mbox series

[2/5] ARM: dts: rockchip: assign a fixed index to mmc devices on rv1108 boards

Message ID 20210118155242.7172-2-jbx6244@gmail.com
State Accepted
Commit 1034e2b6b8435758c0d699b77761365fd09a5f4a
Headers show
Series None | expand

Commit Message

Johan Jonker Jan. 18, 2021, 3:52 p.m. UTC
Recently introduced async probe on mmc devices can shuffle block IDs.
Pin them to fixed values to ease booting in environments where UUIDs are
not practical. Use newly introduced aliases for mmcblk devices from [1].
The sort order is based on reg address.

[1] https://patchwork.kernel.org/patch/11747669/

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---
 arch/arm/boot/dts/rv1108.dtsi | 3 +++
 1 file changed, 3 insertions(+)

Comments

Arnd Bergmann Feb. 9, 2021, 10:25 p.m. UTC | #1
On Mon, Jan 18, 2021 at 4:52 PM Johan Jonker <jbx6244@gmail.com> wrote:
>

> Recently introduced async probe on mmc devices can shuffle block IDs.

> Pin them to fixed values to ease booting in environments where UUIDs are

> not practical. Use newly introduced aliases for mmcblk devices from [1].

> The sort order is based on reg address.

>

> [1] https://patchwork.kernel.org/patch/11747669/


I just saw this in the pull request:

> Signed-off-by: Johan Jonker <jbx6244@gmail.com>

> ---

>  arch/arm/boot/dts/rv1108.dtsi | 3 +++

>  1 file changed, 3 insertions(+)

>

> diff --git a/arch/arm/boot/dts/rv1108.dtsi b/arch/arm/boot/dts/rv1108.dtsi

> index bec47e0be..a754851f4 100644

> --- a/arch/arm/boot/dts/rv1108.dtsi

> +++ b/arch/arm/boot/dts/rv1108.dtsi

> @@ -19,6 +19,9 @@

>                 i2c1 = &i2c1;

>                 i2c2 = &i2c2;

>                 i2c3 = &i2c3;

> +               mmc0 = &emmc;

> +               mmc1 = &sdio;

> +               mmc2 = &sdmmc;

>                 serial0 = &uart0;

>                 serial1 = &uart1;

>                 serial2 = &uart2;


Please don't put these aliases into a .dtsi file, as not every board
will provide each instance. The entire point of the aliases is to
have sane enumeration, so you should start at index 0 for the
first one that is actually present and count up from there.

I would suggest you move these aliases into the .dts files for
the existing boards for the next cycle, and then make sure
only the ones that are present have an alias.

It might actually be a good idea to have a warning in dtc when
there is an alias pointing to a status="disabled" device, but I
suspect there would be a lot of fallout from that.

      Arnd
Heiko Stuebner Feb. 9, 2021, 11:50 p.m. UTC | #2
Am Dienstag, 9. Februar 2021, 23:25:40 CET schrieb Arnd Bergmann:
> On Mon, Jan 18, 2021 at 4:52 PM Johan Jonker <jbx6244@gmail.com> wrote:
> >
> > Recently introduced async probe on mmc devices can shuffle block IDs.
> > Pin them to fixed values to ease booting in environments where UUIDs are
> > not practical. Use newly introduced aliases for mmcblk devices from [1].
> > The sort order is based on reg address.
> >
> > [1] https://patchwork.kernel.org/patch/11747669/
> 
> I just saw this in the pull request:
> 
> > Signed-off-by: Johan Jonker <jbx6244@gmail.com>
> > ---
> >  arch/arm/boot/dts/rv1108.dtsi | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/arch/arm/boot/dts/rv1108.dtsi b/arch/arm/boot/dts/rv1108.dtsi
> > index bec47e0be..a754851f4 100644
> > --- a/arch/arm/boot/dts/rv1108.dtsi
> > +++ b/arch/arm/boot/dts/rv1108.dtsi
> > @@ -19,6 +19,9 @@
> >                 i2c1 = &i2c1;
> >                 i2c2 = &i2c2;
> >                 i2c3 = &i2c3;
> > +               mmc0 = &emmc;
> > +               mmc1 = &sdio;
> > +               mmc2 = &sdmmc;
> >                 serial0 = &uart0;
> >                 serial1 = &uart1;
> >                 serial2 = &uart2;
> 
> Please don't put these aliases into a .dtsi file, as not every board
> will provide each instance. The entire point of the aliases is to
> have sane enumeration, so you should start at index 0 for the
> first one that is actually present and count up from there.

Hmm, right now I don't see the disadvantage of missing mmc numbers.
As similarly we count i2c and serial numbers for a long time, even though
not all of them appear on every board.

Especially as the main goal is to simply have stable numbers and
not having the mmc devices swap numbers on every boot.

So right now we're not using them from a userspace POV but
instead agreed on following the address ordering of the soc.
so when ordering mmc controllers by their io-address, mmc0
is the first one, then mmc1, etc.

So just for my understanding, what is different for mmc?
I guess to guarantee ongoing numbering similar to sd{a,b,c,...}
Or should all aliases be duplicted in each board dts and not
live in any soc dtsi?


Heiko


> I would suggest you move these aliases into the .dts files for
> the existing boards for the next cycle, and then make sure
> only the ones that are present have an alias.
> 
> It might actually be a good idea to have a warning in dtc when
> there is an alias pointing to a status="disabled" device, but I
> suspect there would be a lot of fallout from that.
> 
>       Arnd
>
Arnd Bergmann Feb. 10, 2021, 10:34 a.m. UTC | #3
On Wed, Feb 10, 2021 at 12:50 AM Heiko Stübner <heiko@sntech.de> wrote:
> Am Dienstag, 9. Februar 2021, 23:25:40 CET schrieb Arnd Bergmann:

>

> Hmm, right now I don't see the disadvantage of missing mmc numbers.


It's inconsistent with the normal use of these aliases across other
platforms.

> As similarly we count i2c and serial numbers for a long time, even though

> not all of them appear on every board.


Yes, that is a similar mistake.

> Especially as the main goal is to simply have stable numbers and

> not having the mmc devices swap numbers on every boot.

>

> So right now we're not using them from a userspace POV but

> instead agreed on following the address ordering of the soc.

> so when ordering mmc controllers by their io-address, mmc0

> is the first one, then mmc1, etc.

>

> So just for my understanding, what is different for mmc?

> I guess to guarantee ongoing numbering similar to sd{a,b,c,...}

> Or should all aliases be duplicted in each board dts and not

> live in any soc dtsi?


Each board should have its own aliases node that describes
exactly which of the devices are wired up on that board, and
in which order. If there are connectors on the board that
are labeled in some form, then the aliases are meant to
match what is written on the board or in its documentation.

      Arnd
Heiko Stuebner Feb. 10, 2021, 10:49 a.m. UTC | #4
Am Mittwoch, 10. Februar 2021, 11:34:41 CET schrieb Arnd Bergmann:
> On Wed, Feb 10, 2021 at 12:50 AM Heiko Stübner <heiko@sntech.de> wrote:

> > Am Dienstag, 9. Februar 2021, 23:25:40 CET schrieb Arnd Bergmann:

> >

> > Hmm, right now I don't see the disadvantage of missing mmc numbers.

> 

> It's inconsistent with the normal use of these aliases across other

> platforms.

> 

> > As similarly we count i2c and serial numbers for a long time, even though

> > not all of them appear on every board.

> 

> Yes, that is a similar mistake.

> 

> > Especially as the main goal is to simply have stable numbers and

> > not having the mmc devices swap numbers on every boot.

> >

> > So right now we're not using them from a userspace POV but

> > instead agreed on following the address ordering of the soc.

> > so when ordering mmc controllers by their io-address, mmc0

> > is the first one, then mmc1, etc.

> >

> > So just for my understanding, what is different for mmc?

> > I guess to guarantee ongoing numbering similar to sd{a,b,c,...}

> > Or should all aliases be duplicted in each board dts and not

> > live in any soc dtsi?

> 

> Each board should have its own aliases node that describes

> exactly which of the devices are wired up on that board, and

> in which order. If there are connectors on the board that

> are labeled in some form, then the aliases are meant to

> match what is written on the board or in its documentation.


Then we're at least in the clear for i2c, serial and the rest ... as these
are numbered in the soc documentation, and all boards I've seen so
far use these number also to identify these in schematics.

So an i2c2 is always i2c2 even if i2c1 is not populated.

And of course doing
	i2c0 = &i2c2
would definitly confuse people to no end.

So I guess we'll just move the mmc stuff over to board files.
Arnd Bergmann Feb. 10, 2021, 1:53 p.m. UTC | #5
On Wed, Feb 10, 2021 at 11:49 AM Heiko Stübner <heiko@sntech.de> wrote:
> Am Mittwoch, 10. Februar 2021, 11:34:41 CET schrieb Arnd Bergmann:

> > On Wed, Feb 10, 2021 at 12:50 AM Heiko Stübner <heiko@sntech.de> wrote:

> > > Am Dienstag, 9. Februar 2021, 23:25:40 CET schrieb Arnd Bergmann:

> > Each board should have its own aliases node that describes

> > exactly which of the devices are wired up on that board, and

> > in which order. If there are connectors on the board that

> > are labeled in some form, then the aliases are meant to

> > match what is written on the board or in its documentation.

>

> Then we're at least in the clear for i2c, serial and the rest ... as these

> are numbered in the soc documentation, and all boards I've seen so

> far use these number also to identify these in schematics.


Ok, that is helpful. It would still be good to ensure that only aliases
exist for nodes that are actually enabled.

> So an i2c2 is always i2c2 even if i2c1 is not populated.

>

> And of course doing

>         i2c0 = &i2c2

> would definitly confuse people to no end.


I think that's just an unfortunate choice of the labels here,
it's sometimes easier to just refer to the node by the full
path instead of the label.

      Arnd
diff mbox series

Patch

diff --git a/arch/arm/boot/dts/rv1108.dtsi b/arch/arm/boot/dts/rv1108.dtsi
index bec47e0be..a754851f4 100644
--- a/arch/arm/boot/dts/rv1108.dtsi
+++ b/arch/arm/boot/dts/rv1108.dtsi
@@ -19,6 +19,9 @@ 
 		i2c1 = &i2c1;
 		i2c2 = &i2c2;
 		i2c3 = &i2c3;
+		mmc0 = &emmc;
+		mmc1 = &sdio;
+		mmc2 = &sdmmc;
 		serial0 = &uart0;
 		serial1 = &uart1;
 		serial2 = &uart2;