Skip to contentSkip to conversation

hw/riscv/virt: Comment absence of #msi-cells

PATCH In review Andrew Jones 2 participants 2 messages Sep 25, 2024 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/riscv/virt: Comment absence of #msi-cells

commit 6df664f87c73 ("Revert "hw/riscv/virt.c: imsics DT: add '#msi-cells'"") removed #msi-cells. Now that we have a Linux commit to reference add a comment explaining why it was removed to avoid it getting added back due to DT validation failures.

---
 hw/riscv/virt.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
hw/riscv/virt.c +10 -0
index cef41c150aaf..4fd9c0edf038 100644
@@ -552,6 +552,16 @@ static void create_fdt_one_imsic(RISCVVirtState *s, hwaddr base_addr,
                           FDT_IMSIC_INT_CELLS);
     qemu_fdt_setprop(ms->fdt, imsic_name, "interrupt-controller", NULL, 0);
     qemu_fdt_setprop(ms->fdt, imsic_name, "msi-controller", NULL, 0);
+    /*
+     * Per the DT binding, we should also add #msi-cells with a value of zero.
+     * But, Linux which does not include commit db8e81132cf0 ("of/irq: Support
+     * #msi-cells=<0> in of_msi_get_domain") does not properly handle #msi-cells
+     * with a value of zero. For this reason, the property has intentionally
+     * been left out. It's harmless to not add it since the absence of the
+     * property and a value of zero for the property mean the same thing.
+     * However, since the DT binding requires the property, DT validation may
+     * fail.
+     */
     qemu_fdt_setprop(ms->fdt, imsic_name, "interrupts-extended",
                      imsic_cells, ms->smp.cpus * sizeof(uint32_t) * 2);
     qemu_fdt_setprop(ms->fdt, imsic_name, "reg", imsic_regs,
Signature · 1 line
2.46.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Andrew Jones

commit 6df664f87c73 ("Revert "hw/riscv/virt.c: imsics DT: add '#msi-cells'"") removed #msi-cells. Now that we have a Linux commit to reference add a comment explaining why it was removed to avoid it getting added back due to DT validation failures.

---

Quoted 24 lines
  hw/riscv/virt.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
hw/riscv/virt.c +10 -0
index cef41c150aaf..4fd9c0edf038 100644
@@ -552,6 +552,16 @@ static void create_fdt_one_imsic(RISCVVirtState *s, hwaddr base_addr,
                            FDT_IMSIC_INT_CELLS);
      qemu_fdt_setprop(ms->fdt, imsic_name, "interrupt-controller", NULL, 0);
      qemu_fdt_setprop(ms->fdt, imsic_name, "msi-controller", NULL, 0);
+    /*
+     * Per the DT binding, we should also add #msi-cells with a value of zero.
+     * But, Linux which does not include commit db8e81132cf0 ("of/irq: Support
+     * #msi-cells=<0> in of_msi_get_domain") does not properly handle #msi-cells
+     * with a value of zero. For this reason, the property has intentionally
+     * been left out. It's harmless to not add it since the absence of the
+     * property and a value of zero for the property mean the same thing.
+     * However, since the DT binding requires the property, DT validation may
+     * fail.
+     */
      qemu_fdt_setprop(ms->fdt, imsic_name, "interrupts-extended",
                       imsic_cells, ms->smp.cpus * sizeof(uint32_t) * 2);
      qemu_fdt_setprop(ms->fdt, imsic_name, "reg", imsic_regs,