diff mbox series

[05/10] hw/riscv: use MachineState::fdt in riscv_socket_fdt_write_id()

Message ID 20230111170948.316276-6-dbarboza@ventanamicro.com (mailing list archive)
State New, archived
Headers show
Series riscv: create_fdt() related cleanups | expand

Commit Message

Daniel Henrique Barboza Jan. 11, 2023, 5:09 p.m. UTC
There's no need to use a MachineState pointer and a fdt pointer now that
all RISC-V machines are using the FDT from the MachineState.

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
---
 hw/riscv/numa.c         |  6 +++---
 hw/riscv/spike.c        |  6 +++---
 hw/riscv/virt.c         | 18 +++++++++---------
 include/hw/riscv/numa.h |  6 +++---
 4 files changed, 18 insertions(+), 18 deletions(-)

Comments

Alistair Francis Jan. 16, 2023, 4:01 a.m. UTC | #1
On Thu, Jan 12, 2023 at 3:28 AM Daniel Henrique Barboza
<dbarboza@ventanamicro.com> wrote:
>
> There's no need to use a MachineState pointer and a fdt pointer now that
> all RISC-V machines are using the FDT from the MachineState.
>
> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/riscv/numa.c         |  6 +++---
>  hw/riscv/spike.c        |  6 +++---
>  hw/riscv/virt.c         | 18 +++++++++---------
>  include/hw/riscv/numa.h |  6 +++---
>  4 files changed, 18 insertions(+), 18 deletions(-)
>
> diff --git a/hw/riscv/numa.c b/hw/riscv/numa.c
> index 7fe92d402f..f4343f5cde 100644
> --- a/hw/riscv/numa.c
> +++ b/hw/riscv/numa.c
> @@ -156,11 +156,11 @@ uint64_t riscv_socket_mem_size(const MachineState *ms, int socket_id)
>              ms->numa_state->nodes[socket_id].node_mem : 0;
>  }
>
> -void riscv_socket_fdt_write_id(const MachineState *ms, void *fdt,
> -                               const char *node_name, int socket_id)
> +void riscv_socket_fdt_write_id(const MachineState *ms, const char *node_name,
> +                               int socket_id)
>  {
>      if (numa_enabled(ms)) {
> -        qemu_fdt_setprop_cell(fdt, node_name, "numa-node-id", socket_id);
> +        qemu_fdt_setprop_cell(ms->fdt, node_name, "numa-node-id", socket_id);
>      }
>  }
>
> diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
> index 4a66016d69..05d34651cb 100644
> --- a/hw/riscv/spike.c
> +++ b/hw/riscv/spike.c
> @@ -121,7 +121,7 @@ static void create_fdt(SpikeState *s, const MemMapEntry *memmap,
>              qemu_fdt_setprop_cell(fdt, cpu_name, "reg",
>                  s->soc[socket].hartid_base + cpu);
>              qemu_fdt_setprop_string(fdt, cpu_name, "device_type", "cpu");
> -            riscv_socket_fdt_write_id(mc, fdt, cpu_name, socket);
> +            riscv_socket_fdt_write_id(mc, cpu_name, socket);
>              qemu_fdt_setprop_cell(fdt, cpu_name, "phandle", cpu_phandle);
>
>              intc_name = g_strdup_printf("%s/interrupt-controller", cpu_name);
> @@ -154,7 +154,7 @@ static void create_fdt(SpikeState *s, const MemMapEntry *memmap,
>          qemu_fdt_setprop_cells(fdt, mem_name, "reg",
>              addr >> 32, addr, size >> 32, size);
>          qemu_fdt_setprop_string(fdt, mem_name, "device_type", "memory");
> -        riscv_socket_fdt_write_id(mc, fdt, mem_name, socket);
> +        riscv_socket_fdt_write_id(mc, mem_name, socket);
>          g_free(mem_name);
>
>          clint_addr = memmap[SPIKE_CLINT].base +
> @@ -167,7 +167,7 @@ static void create_fdt(SpikeState *s, const MemMapEntry *memmap,
>              0x0, clint_addr, 0x0, memmap[SPIKE_CLINT].size);
>          qemu_fdt_setprop(fdt, clint_name, "interrupts-extended",
>              clint_cells, s->soc[socket].num_harts * sizeof(uint32_t) * 4);
> -        riscv_socket_fdt_write_id(mc, fdt, clint_name, socket);
> +        riscv_socket_fdt_write_id(mc, clint_name, socket);
>
>          g_free(clint_name);
>          g_free(clint_cells);
> diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
> index 99a0a43a73..1d3bd25cb5 100644
> --- a/hw/riscv/virt.c
> +++ b/hw/riscv/virt.c
> @@ -253,7 +253,7 @@ static void create_fdt_socket_cpus(RISCVVirtState *s, int socket,
>          qemu_fdt_setprop_cell(mc->fdt, cpu_name, "reg",
>              s->soc[socket].hartid_base + cpu);
>          qemu_fdt_setprop_string(mc->fdt, cpu_name, "device_type", "cpu");
> -        riscv_socket_fdt_write_id(mc, mc->fdt, cpu_name, socket);
> +        riscv_socket_fdt_write_id(mc, cpu_name, socket);
>          qemu_fdt_setprop_cell(mc->fdt, cpu_name, "phandle", cpu_phandle);
>
>          intc_phandles[cpu] = (*phandle)++;
> @@ -291,7 +291,7 @@ static void create_fdt_socket_memory(RISCVVirtState *s,
>      qemu_fdt_setprop_cells(mc->fdt, mem_name, "reg",
>          addr >> 32, addr, size >> 32, size);
>      qemu_fdt_setprop_string(mc->fdt, mem_name, "device_type", "memory");
> -    riscv_socket_fdt_write_id(mc, mc->fdt, mem_name, socket);
> +    riscv_socket_fdt_write_id(mc, mem_name, socket);
>      g_free(mem_name);
>  }
>
> @@ -327,7 +327,7 @@ static void create_fdt_socket_clint(RISCVVirtState *s,
>          0x0, clint_addr, 0x0, memmap[VIRT_CLINT].size);
>      qemu_fdt_setprop(mc->fdt, clint_name, "interrupts-extended",
>          clint_cells, s->soc[socket].num_harts * sizeof(uint32_t) * 4);
> -    riscv_socket_fdt_write_id(mc, mc->fdt, clint_name, socket);
> +    riscv_socket_fdt_write_id(mc, clint_name, socket);
>      g_free(clint_name);
>
>      g_free(clint_cells);
> @@ -372,7 +372,7 @@ static void create_fdt_socket_aclint(RISCVVirtState *s,
>              aclint_mswi_cells, aclint_cells_size);
>          qemu_fdt_setprop(mc->fdt, name, "interrupt-controller", NULL, 0);
>          qemu_fdt_setprop_cell(mc->fdt, name, "#interrupt-cells", 0);
> -        riscv_socket_fdt_write_id(mc, mc->fdt, name, socket);
> +        riscv_socket_fdt_write_id(mc, name, socket);
>          g_free(name);
>      }
>
> @@ -396,7 +396,7 @@ static void create_fdt_socket_aclint(RISCVVirtState *s,
>          0x0, RISCV_ACLINT_DEFAULT_MTIME);
>      qemu_fdt_setprop(mc->fdt, name, "interrupts-extended",
>          aclint_mtimer_cells, aclint_cells_size);
> -    riscv_socket_fdt_write_id(mc, mc->fdt, name, socket);
> +    riscv_socket_fdt_write_id(mc, name, socket);
>      g_free(name);
>
>      if (s->aia_type != VIRT_AIA_TYPE_APLIC_IMSIC) {
> @@ -412,7 +412,7 @@ static void create_fdt_socket_aclint(RISCVVirtState *s,
>              aclint_sswi_cells, aclint_cells_size);
>          qemu_fdt_setprop(mc->fdt, name, "interrupt-controller", NULL, 0);
>          qemu_fdt_setprop_cell(mc->fdt, name, "#interrupt-cells", 0);
> -        riscv_socket_fdt_write_id(mc, mc->fdt, name, socket);
> +        riscv_socket_fdt_write_id(mc, name, socket);
>          g_free(name);
>      }
>
> @@ -471,7 +471,7 @@ static void create_fdt_socket_plic(RISCVVirtState *s,
>          0x0, plic_addr, 0x0, memmap[VIRT_PLIC].size);
>      qemu_fdt_setprop_cell(mc->fdt, plic_name, "riscv,ndev",
>                            VIRT_IRQCHIP_NUM_SOURCES - 1);
> -    riscv_socket_fdt_write_id(mc, mc->fdt, plic_name, socket);
> +    riscv_socket_fdt_write_id(mc, plic_name, socket);
>      qemu_fdt_setprop_cell(mc->fdt, plic_name, "phandle",
>          plic_phandles[socket]);
>
> @@ -663,7 +663,7 @@ static void create_fdt_socket_aplic(RISCVVirtState *s,
>          aplic_s_phandle);
>      qemu_fdt_setprop_cells(mc->fdt, aplic_name, "riscv,delegate",
>          aplic_s_phandle, 0x1, VIRT_IRQCHIP_NUM_SOURCES);
> -    riscv_socket_fdt_write_id(mc, mc->fdt, aplic_name, socket);
> +    riscv_socket_fdt_write_id(mc, aplic_name, socket);
>      qemu_fdt_setprop_cell(mc->fdt, aplic_name, "phandle", aplic_m_phandle);
>      g_free(aplic_name);
>
> @@ -691,7 +691,7 @@ static void create_fdt_socket_aplic(RISCVVirtState *s,
>          0x0, aplic_addr, 0x0, memmap[VIRT_APLIC_S].size);
>      qemu_fdt_setprop_cell(mc->fdt, aplic_name, "riscv,num-sources",
>          VIRT_IRQCHIP_NUM_SOURCES);
> -    riscv_socket_fdt_write_id(mc, mc->fdt, aplic_name, socket);
> +    riscv_socket_fdt_write_id(mc, aplic_name, socket);
>      qemu_fdt_setprop_cell(mc->fdt, aplic_name, "phandle", aplic_s_phandle);
>
>      if (!socket) {
> diff --git a/include/hw/riscv/numa.h b/include/hw/riscv/numa.h
> index 1a9cce3344..634df6673f 100644
> --- a/include/hw/riscv/numa.h
> +++ b/include/hw/riscv/numa.h
> @@ -90,10 +90,10 @@ bool riscv_socket_check_hartids(const MachineState *ms, int socket_id);
>   * @ms: pointer to machine state
>   * @socket_id: socket index
>   *
> - * Write NUMA node-id FDT property for given FDT node
> + * Write NUMA node-id FDT property in MachineState->fdt
>   */
> -void riscv_socket_fdt_write_id(const MachineState *ms, void *fdt,
> -                               const char *node_name, int socket_id);
> +void riscv_socket_fdt_write_id(const MachineState *ms, const char *node_name,
> +                               int socket_id);
>
>  /**
>   * riscv_socket_fdt_write_distance_matrix:
> --
> 2.39.0
>
>
diff mbox series

Patch

diff --git a/hw/riscv/numa.c b/hw/riscv/numa.c
index 7fe92d402f..f4343f5cde 100644
--- a/hw/riscv/numa.c
+++ b/hw/riscv/numa.c
@@ -156,11 +156,11 @@  uint64_t riscv_socket_mem_size(const MachineState *ms, int socket_id)
             ms->numa_state->nodes[socket_id].node_mem : 0;
 }
 
-void riscv_socket_fdt_write_id(const MachineState *ms, void *fdt,
-                               const char *node_name, int socket_id)
+void riscv_socket_fdt_write_id(const MachineState *ms, const char *node_name,
+                               int socket_id)
 {
     if (numa_enabled(ms)) {
-        qemu_fdt_setprop_cell(fdt, node_name, "numa-node-id", socket_id);
+        qemu_fdt_setprop_cell(ms->fdt, node_name, "numa-node-id", socket_id);
     }
 }
 
diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
index 4a66016d69..05d34651cb 100644
--- a/hw/riscv/spike.c
+++ b/hw/riscv/spike.c
@@ -121,7 +121,7 @@  static void create_fdt(SpikeState *s, const MemMapEntry *memmap,
             qemu_fdt_setprop_cell(fdt, cpu_name, "reg",
                 s->soc[socket].hartid_base + cpu);
             qemu_fdt_setprop_string(fdt, cpu_name, "device_type", "cpu");
-            riscv_socket_fdt_write_id(mc, fdt, cpu_name, socket);
+            riscv_socket_fdt_write_id(mc, cpu_name, socket);
             qemu_fdt_setprop_cell(fdt, cpu_name, "phandle", cpu_phandle);
 
             intc_name = g_strdup_printf("%s/interrupt-controller", cpu_name);
@@ -154,7 +154,7 @@  static void create_fdt(SpikeState *s, const MemMapEntry *memmap,
         qemu_fdt_setprop_cells(fdt, mem_name, "reg",
             addr >> 32, addr, size >> 32, size);
         qemu_fdt_setprop_string(fdt, mem_name, "device_type", "memory");
-        riscv_socket_fdt_write_id(mc, fdt, mem_name, socket);
+        riscv_socket_fdt_write_id(mc, mem_name, socket);
         g_free(mem_name);
 
         clint_addr = memmap[SPIKE_CLINT].base +
@@ -167,7 +167,7 @@  static void create_fdt(SpikeState *s, const MemMapEntry *memmap,
             0x0, clint_addr, 0x0, memmap[SPIKE_CLINT].size);
         qemu_fdt_setprop(fdt, clint_name, "interrupts-extended",
             clint_cells, s->soc[socket].num_harts * sizeof(uint32_t) * 4);
-        riscv_socket_fdt_write_id(mc, fdt, clint_name, socket);
+        riscv_socket_fdt_write_id(mc, clint_name, socket);
 
         g_free(clint_name);
         g_free(clint_cells);
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index 99a0a43a73..1d3bd25cb5 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -253,7 +253,7 @@  static void create_fdt_socket_cpus(RISCVVirtState *s, int socket,
         qemu_fdt_setprop_cell(mc->fdt, cpu_name, "reg",
             s->soc[socket].hartid_base + cpu);
         qemu_fdt_setprop_string(mc->fdt, cpu_name, "device_type", "cpu");
-        riscv_socket_fdt_write_id(mc, mc->fdt, cpu_name, socket);
+        riscv_socket_fdt_write_id(mc, cpu_name, socket);
         qemu_fdt_setprop_cell(mc->fdt, cpu_name, "phandle", cpu_phandle);
 
         intc_phandles[cpu] = (*phandle)++;
@@ -291,7 +291,7 @@  static void create_fdt_socket_memory(RISCVVirtState *s,
     qemu_fdt_setprop_cells(mc->fdt, mem_name, "reg",
         addr >> 32, addr, size >> 32, size);
     qemu_fdt_setprop_string(mc->fdt, mem_name, "device_type", "memory");
-    riscv_socket_fdt_write_id(mc, mc->fdt, mem_name, socket);
+    riscv_socket_fdt_write_id(mc, mem_name, socket);
     g_free(mem_name);
 }
 
@@ -327,7 +327,7 @@  static void create_fdt_socket_clint(RISCVVirtState *s,
         0x0, clint_addr, 0x0, memmap[VIRT_CLINT].size);
     qemu_fdt_setprop(mc->fdt, clint_name, "interrupts-extended",
         clint_cells, s->soc[socket].num_harts * sizeof(uint32_t) * 4);
-    riscv_socket_fdt_write_id(mc, mc->fdt, clint_name, socket);
+    riscv_socket_fdt_write_id(mc, clint_name, socket);
     g_free(clint_name);
 
     g_free(clint_cells);
@@ -372,7 +372,7 @@  static void create_fdt_socket_aclint(RISCVVirtState *s,
             aclint_mswi_cells, aclint_cells_size);
         qemu_fdt_setprop(mc->fdt, name, "interrupt-controller", NULL, 0);
         qemu_fdt_setprop_cell(mc->fdt, name, "#interrupt-cells", 0);
-        riscv_socket_fdt_write_id(mc, mc->fdt, name, socket);
+        riscv_socket_fdt_write_id(mc, name, socket);
         g_free(name);
     }
 
@@ -396,7 +396,7 @@  static void create_fdt_socket_aclint(RISCVVirtState *s,
         0x0, RISCV_ACLINT_DEFAULT_MTIME);
     qemu_fdt_setprop(mc->fdt, name, "interrupts-extended",
         aclint_mtimer_cells, aclint_cells_size);
-    riscv_socket_fdt_write_id(mc, mc->fdt, name, socket);
+    riscv_socket_fdt_write_id(mc, name, socket);
     g_free(name);
 
     if (s->aia_type != VIRT_AIA_TYPE_APLIC_IMSIC) {
@@ -412,7 +412,7 @@  static void create_fdt_socket_aclint(RISCVVirtState *s,
             aclint_sswi_cells, aclint_cells_size);
         qemu_fdt_setprop(mc->fdt, name, "interrupt-controller", NULL, 0);
         qemu_fdt_setprop_cell(mc->fdt, name, "#interrupt-cells", 0);
-        riscv_socket_fdt_write_id(mc, mc->fdt, name, socket);
+        riscv_socket_fdt_write_id(mc, name, socket);
         g_free(name);
     }
 
@@ -471,7 +471,7 @@  static void create_fdt_socket_plic(RISCVVirtState *s,
         0x0, plic_addr, 0x0, memmap[VIRT_PLIC].size);
     qemu_fdt_setprop_cell(mc->fdt, plic_name, "riscv,ndev",
                           VIRT_IRQCHIP_NUM_SOURCES - 1);
-    riscv_socket_fdt_write_id(mc, mc->fdt, plic_name, socket);
+    riscv_socket_fdt_write_id(mc, plic_name, socket);
     qemu_fdt_setprop_cell(mc->fdt, plic_name, "phandle",
         plic_phandles[socket]);
 
@@ -663,7 +663,7 @@  static void create_fdt_socket_aplic(RISCVVirtState *s,
         aplic_s_phandle);
     qemu_fdt_setprop_cells(mc->fdt, aplic_name, "riscv,delegate",
         aplic_s_phandle, 0x1, VIRT_IRQCHIP_NUM_SOURCES);
-    riscv_socket_fdt_write_id(mc, mc->fdt, aplic_name, socket);
+    riscv_socket_fdt_write_id(mc, aplic_name, socket);
     qemu_fdt_setprop_cell(mc->fdt, aplic_name, "phandle", aplic_m_phandle);
     g_free(aplic_name);
 
@@ -691,7 +691,7 @@  static void create_fdt_socket_aplic(RISCVVirtState *s,
         0x0, aplic_addr, 0x0, memmap[VIRT_APLIC_S].size);
     qemu_fdt_setprop_cell(mc->fdt, aplic_name, "riscv,num-sources",
         VIRT_IRQCHIP_NUM_SOURCES);
-    riscv_socket_fdt_write_id(mc, mc->fdt, aplic_name, socket);
+    riscv_socket_fdt_write_id(mc, aplic_name, socket);
     qemu_fdt_setprop_cell(mc->fdt, aplic_name, "phandle", aplic_s_phandle);
 
     if (!socket) {
diff --git a/include/hw/riscv/numa.h b/include/hw/riscv/numa.h
index 1a9cce3344..634df6673f 100644
--- a/include/hw/riscv/numa.h
+++ b/include/hw/riscv/numa.h
@@ -90,10 +90,10 @@  bool riscv_socket_check_hartids(const MachineState *ms, int socket_id);
  * @ms: pointer to machine state
  * @socket_id: socket index
  *
- * Write NUMA node-id FDT property for given FDT node
+ * Write NUMA node-id FDT property in MachineState->fdt
  */
-void riscv_socket_fdt_write_id(const MachineState *ms, void *fdt,
-                               const char *node_name, int socket_id);
+void riscv_socket_fdt_write_id(const MachineState *ms, const char *node_name,
+                               int socket_id);
 
 /**
  * riscv_socket_fdt_write_distance_matrix: