[PATCH 4/5] hw/or1k: Use hex unit addresses in FDT CPU nodes

Vivian Wang posted 5 patches 2 days, 10 hours ago
Maintainers: Peter Maydell <peter.maydell@linaro.org>, Leif Lindholm <leif.lindholm@oss.qualcomm.com>, Song Gao <gaosong@loongson.cn>, Bibo Mao <maobibo@loongson.cn>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Paul Burton <paulburton@kernel.org>, Aleksandar Rikalo <arikalo@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Jia Liu <proljc@gmail.com>, Stafford Horne <shorne@gmail.com>, Alistair Francis <Alistair.Francis@wdc.com>, Palmer Dabbelt <palmer@dabbelt.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Chao Liu <chao.liu.zevorn@gmail.com>
[PATCH 4/5] hw/or1k: Use hex unit addresses in FDT CPU nodes
Posted by Vivian Wang 2 days, 10 hours ago
These unit addresses should have been in hex, not decimal, as per de
facto convention [1]. Fix them.

Link: https://lore.kernel.org/devicetree-spec/CAL_JsqJFv3+UJ-bjLGk0i7Wc+spsowCrqQZ_s3P4gN8r1W-Q-w@mail.gmail.com/ # [1]
Signed-off-by: Vivian Wang <wangruikang@iscas.ac.cn>
---
 hw/or1k/or1k-sim.c | 2 +-
 hw/or1k/virt.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/or1k/or1k-sim.c b/hw/or1k/or1k-sim.c
index f1b1f63274..b851e48c16 100644
--- a/hw/or1k/or1k-sim.c
+++ b/hw/or1k/or1k-sim.c
@@ -138,7 +138,7 @@ static void openrisc_create_fdt(Or1ksimState *state,
     qemu_fdt_setprop_cell(fdt, "/cpus", "#address-cells", 0x1);
 
     for (cpu = 0; cpu < num_cpus; cpu++) {
-        nodename = g_strdup_printf("/cpus/cpu@%d", cpu);
+        nodename = g_strdup_printf("/cpus/cpu@%x", (unsigned)cpu);
         qemu_fdt_add_subnode(fdt, nodename);
         qemu_fdt_setprop_string(fdt, nodename, "compatible",
                                 "opencores,or1200-rtlsvn481");
diff --git a/hw/or1k/virt.c b/hw/or1k/virt.c
index 39f54058ab..ac644f128e 100644
--- a/hw/or1k/virt.c
+++ b/hw/or1k/virt.c
@@ -162,7 +162,7 @@ static void openrisc_create_fdt(OR1KVirtState *state,
     qemu_fdt_setprop_cell(fdt, "/cpus", "#address-cells", 0x1);
 
     for (cpu = 0; cpu < num_cpus; cpu++) {
-        nodename = g_strdup_printf("/cpus/cpu@%d", cpu);
+        nodename = g_strdup_printf("/cpus/cpu@%x", (unsigned)cpu);
         qemu_fdt_add_subnode(fdt, nodename);
         qemu_fdt_setprop_string(fdt, nodename, "compatible",
                                 "opencores,or1200-rtlsvn481");

-- 
2.53.0
Re: [PATCH 4/5] hw/or1k: Use hex unit addresses in FDT CPU nodes
Posted by Peter Maydell 2 days, 7 hours ago
On Thu, 9 Apr 2026 at 07:40, Vivian Wang <wangruikang@iscas.ac.cn> wrote:
>
> These unit addresses should have been in hex, not decimal, as per de
> facto convention [1]. Fix them.
>
> Link: https://lore.kernel.org/devicetree-spec/CAL_JsqJFv3+UJ-bjLGk0i7Wc+spsowCrqQZ_s3P4gN8r1W-Q-w@mail.gmail.com/ # [1]
> Signed-off-by: Vivian Wang <wangruikang@iscas.ac.cn>
> ---
>  hw/or1k/or1k-sim.c | 2 +-
>  hw/or1k/virt.c     | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/or1k/or1k-sim.c b/hw/or1k/or1k-sim.c
> index f1b1f63274..b851e48c16 100644
> --- a/hw/or1k/or1k-sim.c
> +++ b/hw/or1k/or1k-sim.c
> @@ -138,7 +138,7 @@ static void openrisc_create_fdt(Or1ksimState *state,
>      qemu_fdt_setprop_cell(fdt, "/cpus", "#address-cells", 0x1);
>
>      for (cpu = 0; cpu < num_cpus; cpu++) {
> -        nodename = g_strdup_printf("/cpus/cpu@%d", cpu);
> +        nodename = g_strdup_printf("/cpus/cpu@%x", (unsigned)cpu);
>          qemu_fdt_add_subnode(fdt, nodename);
>          qemu_fdt_setprop_string(fdt, nodename, "compatible",
>                                  "opencores,or1200-rtlsvn481");
> diff --git a/hw/or1k/virt.c b/hw/or1k/virt.c
> index 39f54058ab..ac644f128e 100644
> --- a/hw/or1k/virt.c
> +++ b/hw/or1k/virt.c
> @@ -162,7 +162,7 @@ static void openrisc_create_fdt(OR1KVirtState *state,
>      qemu_fdt_setprop_cell(fdt, "/cpus", "#address-cells", 0x1);
>
>      for (cpu = 0; cpu < num_cpus; cpu++) {
> -        nodename = g_strdup_printf("/cpus/cpu@%d", cpu);
> +        nodename = g_strdup_printf("/cpus/cpu@%x", (unsigned)cpu);
>          qemu_fdt_add_subnode(fdt, nodename);
>          qemu_fdt_setprop_string(fdt, nodename, "compatible",
>                                  "opencores,or1200-rtlsvn481");

The maximum number of CPUs in both these boards is 4, so this makes
no actual difference to the node names we create. That would be
worth noting in the commit message.

-- PMM
Re: [PATCH 4/5] hw/or1k: Use hex unit addresses in FDT CPU nodes
Posted by Philippe Mathieu-Daudé 2 days, 7 hours ago
On 9/4/26 08:40, Vivian Wang wrote:
> These unit addresses should have been in hex, not decimal, as per de
> facto convention [1]. Fix them.
> 
> Link: https://lore.kernel.org/devicetree-spec/CAL_JsqJFv3+UJ-bjLGk0i7Wc+spsowCrqQZ_s3P4gN8r1W-Q-w@mail.gmail.com/ # [1]
> Signed-off-by: Vivian Wang <wangruikang@iscas.ac.cn>
> ---
>   hw/or1k/or1k-sim.c | 2 +-
>   hw/or1k/virt.c     | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/or1k/or1k-sim.c b/hw/or1k/or1k-sim.c
> index f1b1f63274..b851e48c16 100644
> --- a/hw/or1k/or1k-sim.c
> +++ b/hw/or1k/or1k-sim.c
> @@ -138,7 +138,7 @@ static void openrisc_create_fdt(Or1ksimState *state,
>       qemu_fdt_setprop_cell(fdt, "/cpus", "#address-cells", 0x1);
>   
>       for (cpu = 0; cpu < num_cpus; cpu++) {
> -        nodename = g_strdup_printf("/cpus/cpu@%d", cpu);
> +        nodename = g_strdup_printf("/cpus/cpu@%x", (unsigned)cpu);

No need to cast to unsigned explicitly, otherwise:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>