Skip to contentSkip to conversation

hw/arm/virt: fix dtb nits spotted by dtc

PATCH In review Peter Maydell 2 participants 5 messages May 13, 2022

lore
Share & tools
lore
#0 lore raw

cover hw/arm/virt: fix dtb nits spotted by dtc

If you dump the DTB generated by the virt board using
-machine dumpdtb=file.dtb
and then decompile it with
dtc -I dtb -O dts -o file.dts file.dtb
dtc will complain about some harmless but wrong constructs in the dtb:

Warning (unique_unit_address): /flash@0: duplicate unit-address (also used in node /secflash@0)
Warning (avoid_unnecessary_addr_size): /gpio-keys: unnecessary #address-cells/#size-cells without "ranges" or child "reg" property

This series fixes those nits.

thanks
-- PMM

Peter Maydell (2):
hw/arm/virt: Fix incorrect non-secure flash dtb node name hw/arm/virt: Drop #size-cells and #address-cells from gpio-keys dtb
node

 hw/arm/virt.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 hw/arm/virt: Fix incorrect non-secure flash dtb node name

In the virt board with secure=on we put two nodes in the dtb for flash devices: one for the secure-only flash, and one for the non-secure flash. We get the reg properties for these correct, but in the DT node name, which by convention includes the base address of devices, we used the wrong address. Fix it.

Spotted by dtc, which will complain
Warning (unique_unit_address): /flash@0: duplicate unit-address (also used in node /secflash@0) if you dump the dtb from QEMU with -machine dumpdtb=file.dtb
and then decompile it with dtc.

---
 hw/arm/virt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/virt.c +1 -1
index 1a45f44435e..587e885a98c 100644
@@ -1195,7 +1195,7 @@ static void virt_flash_fdt(VirtMachineState *vms,
         qemu_fdt_setprop_string(ms->fdt, nodename, "secure-status", "okay");
         g_free(nodename);
 
-        nodename = g_strdup_printf("/flash@%" PRIx64, flashbase);
+        nodename = g_strdup_printf("/flash@%" PRIx64, flashbase + flashsize);
         qemu_fdt_add_subnode(ms->fdt, nodename);
         qemu_fdt_setprop_string(ms->fdt, nodename, "compatible", "cfi-flash");
         qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "reg",
Signature · 1 line
2.25.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] hw/arm/virt: Fix incorrect non-secure flash dtb node name

Quoted 11 lines · Peter Maydell

In the virt board with secure=on we put two nodes in the dtb for flash devices: one for the secure-only flash, and one for the non-secure flash. We get the reg properties for these correct, but in the DT node name, which by convention includes the base address of devices, we used the wrong address. Fix it.

Spotted by dtc, which will complain
Warning (unique_unit_address): /flash@0: duplicate unit-address (also used in node /secflash@0) if you dump the dtb from QEMU with -machine dumpdtb=file.dtb
and then decompile it with dtc.

Quoted 4 lines
---
  hw/arm/virt.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

r~

#3 lore raw

PATCH 2/2 hw/arm/virt: Drop #size-cells and #address-cells from gpio-keys dtb node

In reply to Peter Maydell

The virt board generates a gpio-keys node in the dtb, but it incorrectly gives this node #size-cells and #address-cells properties. If you dump the dtb with 'machine dumpdtb=file.dtb' and run it through dtc, dtc will warn about this:

Warning (avoid_unnecessary_addr_size): /gpio-keys: unnecessary #address-cells/#size-cells without "ranges" or child "reg" property

Remove the bogus properties.

---
 hw/arm/virt.c | 2 --
 1 file changed, 2 deletions(-)
hw/arm/virt.c +0 -2
index 587e885a98c..097238faa7a 100644
@@ -925,8 +925,6 @@ static void create_gpio_keys(char *fdt, DeviceState *pl061_dev,
 
     qemu_fdt_add_subnode(fdt, "/gpio-keys");
     qemu_fdt_setprop_string(fdt, "/gpio-keys", "compatible", "gpio-keys");
-    qemu_fdt_setprop_cell(fdt, "/gpio-keys", "#size-cells", 0);
-    qemu_fdt_setprop_cell(fdt, "/gpio-keys", "#address-cells", 1);
 
     qemu_fdt_add_subnode(fdt, "/gpio-keys/poweroff");
     qemu_fdt_setprop_string(fdt, "/gpio-keys/poweroff",
Signature · 1 line
2.25.1
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] hw/arm/virt: Drop #size-cells and #address-cells from gpio-keys dtb node

Quoted 5 lines · Peter Maydell

The virt board generates a gpio-keys node in the dtb, but it incorrectly gives this node #size-cells and #address-cells properties. If you dump the dtb with 'machine dumpdtb=file.dtb' and run it through dtc, dtc will warn about this:

Quoted 8 lines

Warning (avoid_unnecessary_addr_size):/gpio-keys: unnecessary #address-cells/#size-cells without "ranges" or child "reg" property

Remove the bogus properties.

---
  hw/arm/virt.c | 2 --
  1 file changed, 2 deletions(-)

r~