]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/riscv/numa: make numa_enabled() public
authorDaniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>
Mon, 15 Jun 2026 20:37:23 +0000 (17:37 -0300)
committerAlistair Francis <alistair.francis@wdc.com>
Tue, 16 Jun 2026 10:01:11 +0000 (20:01 +1000)
There's FDT logic gated around 'numa_enabled()' in virt.c and spike.c.
We want to move the FDT code to a common helper without having to call
hw/riscv/numa.c functions from it, but at the same time being aware of
the FDT changes if numa is enabled.

To do that the boards will inform the FDT helpers if we have
numa_enabled in the env or not.  And for the boards to be able to do
that we need the static 'numa_enabled' function to be public.

Signed-off-by: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260615203734.954428-4-daniel.barboza@oss.qualcomm.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
hw/riscv/numa.c
include/hw/riscv/numa.h

index 8a144925c1ca5beacdb809efb8e9574be21ed87b..8933d9d81f2b9263b9fdafbafdeb2508b1370ca9 100644 (file)
 #include "hw/riscv/numa.h"
 #include "system/device_tree.h"
 
-static bool numa_enabled(const MachineState *ms)
+bool riscv_numa_enabled(const MachineState *ms)
 {
     return (ms->numa_state && ms->numa_state->num_nodes) ? true : false;
 }
 
 int riscv_socket_count(const MachineState *ms)
 {
-    return (numa_enabled(ms)) ? ms->numa_state->num_nodes : 1;
+    return (riscv_numa_enabled(ms)) ? ms->numa_state->num_nodes : 1;
 }
 
 int riscv_socket_first_hartid(const MachineState *ms, int socket_id)
 {
     int i, first_hartid = ms->smp.cpus;
 
-    if (!numa_enabled(ms)) {
+    if (!riscv_numa_enabled(ms)) {
         return (!socket_id) ? 0 : -1;
     }
 
@@ -59,7 +59,7 @@ int riscv_socket_last_hartid(const MachineState *ms, int socket_id)
 {
     int i, last_hartid = -1;
 
-    if (!numa_enabled(ms)) {
+    if (!riscv_numa_enabled(ms)) {
         return (!socket_id) ? ms->smp.cpus - 1 : -1;
     }
 
@@ -79,7 +79,7 @@ int riscv_socket_hart_count(const MachineState *ms, int socket_id)
 {
     int first_hartid, last_hartid;
 
-    if (!numa_enabled(ms)) {
+    if (!riscv_numa_enabled(ms)) {
         return (!socket_id) ? ms->smp.cpus : -1;
     }
 
@@ -104,7 +104,7 @@ bool riscv_socket_check_hartids(const MachineState *ms, int socket_id)
 {
     int i, first_hartid, last_hartid;
 
-    if (!numa_enabled(ms)) {
+    if (!riscv_numa_enabled(ms)) {
         return (!socket_id) ? true : false;
     }
 
@@ -132,7 +132,7 @@ uint64_t riscv_socket_mem_offset(const MachineState *ms, int socket_id)
     int i;
     uint64_t mem_offset = 0;
 
-    if (!numa_enabled(ms)) {
+    if (!riscv_numa_enabled(ms)) {
         return 0;
     }
 
@@ -148,7 +148,7 @@ uint64_t riscv_socket_mem_offset(const MachineState *ms, int socket_id)
 
 uint64_t riscv_socket_mem_size(const MachineState *ms, int socket_id)
 {
-    if (!numa_enabled(ms)) {
+    if (!riscv_numa_enabled(ms)) {
         return (!socket_id) ? ms->ram_size : 0;
     }
 
@@ -159,7 +159,7 @@ uint64_t riscv_socket_mem_size(const MachineState *ms, int socket_id)
 void riscv_socket_fdt_write_id(const MachineState *ms, const char *node_name,
                                int socket_id)
 {
-    if (numa_enabled(ms)) {
+    if (riscv_numa_enabled(ms)) {
         qemu_fdt_setprop_cell(ms->fdt, node_name, "numa-node-id", socket_id);
     }
 }
@@ -170,7 +170,7 @@ void riscv_socket_fdt_write_distance_matrix(const MachineState *ms)
     g_autofree uint32_t *dist_matrix = NULL;
     uint32_t dist_matrix_size;
 
-    if (numa_enabled(ms) && ms->numa_state->have_numa_distance) {
+    if (riscv_numa_enabled(ms) && ms->numa_state->have_numa_distance) {
         dist_matrix_size = riscv_socket_count(ms) * riscv_socket_count(ms);
         dist_matrix_size *= (3 * sizeof(uint32_t));
         dist_matrix = g_malloc0(dist_matrix_size);
index e68ce8e8afdb42801719c2558fa11316a1f787a4..ac07786555b53455fd5f8bc7fa7d5945b8355ef5 100644 (file)
 #include "hw/core/sysbus.h"
 #include "system/numa.h"
 
+/**
+ * riscv_numa_enabled:
+ * @ms: pointer to machine state
+ *
+ * Returns: true if NUMA is enabled in the machine state.
+ */
+bool riscv_numa_enabled(const MachineState *ms);
+
 /**
  * riscv_socket_count:
  * @ms: pointer to machine state