Devicetree spec: Specifying /cpus/cpu@* unit address format?
Vivian Wang <[email protected]> Fri, 3 Apr 2026 18:06:17 +0800
| Newsgroups | org.kernel.vger.devicetree-spec,dev.linux.lists.sophgo,org.infradead.lists.linux-riscv,org.kernel.vger.linux-devicetree |
|---|---|
| Message-ID | <[email protected]> |
(Also posted at: https://github.com/devicetree-org/devicetree-specificati=
on/issues/86 )
Hi all,
Presently, there seems to be some confusion in the community about the
format of unit addresses for "/cpus/cpu@*" nodes for a CPU with ID > 9, e=
=2Eg.
=C2=A0 =C2=A0 cpu@??? {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 reg =3D <10>;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 /* reg =3D <0xa>; */ /* This should be equiva=
lent */
=C2=A0 =C2=A0 }
Should this be a decimal "cpu@10", or hexadecimal "cpu@a"? I can't find
any explicit specification.
* Most other nodes specify a hex unit address
* I could not find anything specifying this generically
o AFAICT, there's no /cpus in IEEE 1275
o ePAPR doesn't say anything about this
o Presently, DTSpec doesn't say anything about this.
* dt-schema says it's ^cpu@[0-9a-f]+$, seemingly intending to use
hexadecimal, but not forbidding decimal. [1]
* Of the `/cpus` schemas in Linux
(Documentation/devicetree/bindings/{arm,mips,riscv,loongarch}/cpus.ya=
ml),
none mention the node unit address
As of current usage:
* Of all the DTS files in (mainline) Linux, most either use hex, or
have reg < 9 for all CPUs.
o AFAICT from grepping, arm and arm64 consistently uses hex.
o Most riscv SoCs have <=3D 9 CPUs. The two that don't use decimal:=
arch/riscv/boot/dts/sophgo/{sg2042,sg2044}-cpus.dtsi
o No other arch has in-tree DTS with CPU reg > 9
* Of all the dt-bindings examples in Linux, only one uses decimal, but
it seems to be unintentional:
Documentation/devicetree/bindings/opp/opp-v2.yaml
* QEMU generates decimal for multiple archs in e.g.
`hw/{arm,riscv}/virt.c` and other places (grep -R "cpu@")
* Spike (RISC-V emulator) generates decimal [3]
It could be a good idea to have this standardized, like all other unit
addresses.
DTSpec says:
=C2=A0 The binding for a particular bus may specify additional, more spec=
ific
requirements for the format of reg and the unit-address.
Since /cpus and /cpus/cpu@* are generically defined in DTSpec and
specialized for various architectures, I believe this is the right place
to start standardizing this. Even if arch-specific definitions are
required, at least DTSpec can give a recommendation on whether to use
decimal or hexadecimal.
Thanks,
Vivian "dramforever" Wang
[1]: https://github.com/devicetree-org/dt-schema/blob/v2025.12/dtschema/s=
chemas/cpus.yaml#L52-L54
[2]: https://github.com/riscv-software-src/riscv-isa-sim/blob/5eeeb91efa9=
66936ef7b980f5e8dd00ffbe70786/riscv/dts.cc#L61