Re: SoC-specific device tree aliases?

Ahmad Fatoum <[email protected]> Wed, 3 Dec 2025 12:34:45 +0100
Newsgroups org.kernel.vger.devicetree-spec,org.kernel.vger.linux-devicetree
Message-ID <[email protected]>
Hello Krzysztof,

On 12/3/25 11:25 AM, Krzysztof Kozlowski wrote:
> On 03/12/2025 11:16, Ahmad Fatoum wrote:
>>> Just because ufs/mmc/spi can be used that way, does not mean we should
>>> accept any possible alias into soc.dtsi.
>>
>> I can't see how this could work. A number of boards renumber MMC devices
>> in a different manner than the SoC reference manual:
>>
>> - Changing the alias numbering is an ABI break, because Linux derives
>> its /dev/mmcblkX numbering from it
> 
> First, why the alias would change? Isn't the board following the SoC
> numbering in 99.9% cases?

For 32-bit i.MX, the figure is more like 80% with 20% of the boards
going out of their way to override the numbering in the SoC dtsi.

I can only assume the figure may be higher for other platforms, where
there is no numbering in the DTSI. See below[1] for calculation.

> Second, I don't think it is an ABI. We had it ~5 or ~8 years ago where
> the mmcblkX was changing based on probe ordering. Many people setups got
> broken, many people complained and the consensus reply was: please start
> finally using UUID/PARTUIID/LABEL for rootfs.

On the other hand, I have seen people flashing the same image to both an
eMMC and a SD-Card and wondering why the bootloader picks a different
rootfs than the kernel.

> Eventually we got back to
> mmcblkX stability but rule is there - if your cmdline has /dev/mmcblkX,
> then it is your problem.

Device tree aliases are the only way to identify the same MMC device
in bootloader and kernel over different boots and for my part, I can
only encourage their use.

[1]: I checked out Linux v6.18, used imx_v6_v7_defconfig and built the
dtb target.

arch/arm/boot/dts/nxp/imx/.*.dtb.dts.tmp in the build directory are the
preprocessed device tree source files.

I deleted arch/arm/boot/dts/nxp/imx/.imx7ulp*.dtb.dts.tmp, because
it's the only SoC apparently that numbers MMC peripherals stating with 0.

Now let's find all instances of mmcX = somethingY, where X is not Y - 1:

perl -ne '/mmc(\d+)\s*=\s*&\w+?(\d+)/ && $1 != $2 - 1 and \
	print($ARGV, $_) && close ARGV' \
		arch/arm/boot/dts/nxp/imx/.*.dtb.dts.tmp

This returns 76 matches out of a total 381, so that's 19.95% of all i.MX
device trees that went out of their way to override the numbering in the
SoC dtsi.

Cheers,
Ahmad

> 
> 
> 
> 
> Best regards,
> Krzysztof
> 

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |