Skip to contentSkip to conversation

hw/arm/virt: numa: provide distance info when needed

PATCH Applied Andrew Jones 4 participants 7 messages May 29, 2017 – Jun 1, 2017

lore
Share & tools
lore
#0 lore raw

cover hw/arm/virt: numa: provide distance info when needed

Andrew Jones (2):
hw/arm/virt-acpi-build: build SLIT when needed hw/arm/virt: fdt: generate distance-map when needed

 hw/arm/virt-acpi-build.c |  4 ++++
 hw/arm/virt.c            | 21 +++++++++++++++++++++
 2 files changed, 25 insertions(+)
Signature · 1 line
2.9.4
#1 lore raw

PATCH 1/2 hw/arm/virt-acpi-build: build SLIT when needed

---
 hw/arm/virt-acpi-build.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/arm/virt-acpi-build.c +4 -0
index e5852067f5bd..2079828c22a4 100644
@@ -776,6 +776,10 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
     if (nb_numa_nodes > 0) {
         acpi_add_table(table_offsets, tables_blob);
         build_srat(tables_blob, tables->linker, vms);
+        if (have_numa_distance) {
+            acpi_add_table(table_offsets, tables_blob);
+            build_slit(tables_blob, tables->linker);
+        }
     }
 
     if (its_class_name() && !vmc->no_its) {
Signature · 1 line
2.9.4
#4 lore raw

PATCH 2/2 hw/arm/virt: fdt: generate distance-map when needed

In reply to Andrew Jones

This is based on patch Shannon Zhao originally posted.

---
 hw/arm/virt.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
hw/arm/virt.c +21 -0
index c7c8159dfd59..4db2d4207cf2 100644
@@ -219,6 +219,27 @@ static void create_fdt(VirtMachineState *vms)
                                 "clk24mhz");
     qemu_fdt_setprop_cell(fdt, "/apb-pclk", "phandle", vms->clock_phandle);
 
+    if (have_numa_distance) {
+        int size = nb_numa_nodes * nb_numa_nodes * 3 * sizeof(uint32_t);
+        uint32_t *matrix = g_malloc0(size);
+        int idx, i, j;
+
+        for (i = 0; i < nb_numa_nodes; i++) {
+            for (j = 0; j < nb_numa_nodes; j++) {
+                idx = (i * nb_numa_nodes + j) * 3;
+                matrix[idx + 0] = cpu_to_be32(i);
+                matrix[idx + 1] = cpu_to_be32(j);
+                matrix[idx + 2] = cpu_to_be32(numa_info[i].distance[j]);
+            }
+        }
+
+        qemu_fdt_add_subnode(fdt, "/distance-map");
+        qemu_fdt_setprop_string(fdt, "/distance-map", "compatible",
+                                "numa-distance-map-v1");
+        qemu_fdt_setprop(fdt, "/distance-map", "distance-matrix",
+                         matrix, size);
+        g_free(matrix);
+    }
 }
 
 static void fdt_add_psci_node(const VirtMachineState *vms)
Signature · 1 line
2.9.4
Reviewed-by on v1 1/2
#2 lore raw

Re: [Qemu-arm] [Qemu-devel] [PATCH 1/2] hw/arm/virt-acpi-build: build SLIT when needed

In reply to Andrew Jones
Quoted 2 lines · On Mon, 29 May 2017 19:37:50 +0200 Andrew Jones <[email protected]> wrote:
Quoted 19 lines
---
 hw/arm/virt-acpi-build.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/arm/virt-acpi-build.c +4 -0
index e5852067f5bd..2079828c22a4 100644
@@ -776,6 +776,10 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
     if (nb_numa_nodes > 0) {
         acpi_add_table(table_offsets, tables_blob);
         build_srat(tables_blob, tables->linker, vms);
+        if (have_numa_distance) {
+            acpi_add_table(table_offsets, tables_blob);
+            build_slit(tables_blob, tables->linker);
+        }
     }
 
     if (its_class_name() && !vmc->no_its) {
Reviewed-by on v1 2/2
#5 lore raw

Re: [Qemu-arm] [PATCH 2/2] hw/arm/virt: fdt: generate distance-map when needed

In reply to Andrew Jones
Quoted 4 lines · Andrew Jones

This is based on patch Shannon Zhao originally posted.

Quoted 37 lines
---
 hw/arm/virt.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
hw/arm/virt.c +21 -0
index c7c8159dfd59..4db2d4207cf2 100644
@@ -219,6 +219,27 @@ static void create_fdt(VirtMachineState *vms)
                                 "clk24mhz");
     qemu_fdt_setprop_cell(fdt, "/apb-pclk", "phandle", vms->clock_phandle);
 
+    if (have_numa_distance) {
+        int size = nb_numa_nodes * nb_numa_nodes * 3 * sizeof(uint32_t);
+        uint32_t *matrix = g_malloc0(size);
+        int idx, i, j;
+
+        for (i = 0; i < nb_numa_nodes; i++) {
+            for (j = 0; j < nb_numa_nodes; j++) {
+                idx = (i * nb_numa_nodes + j) * 3;
+                matrix[idx + 0] = cpu_to_be32(i);
+                matrix[idx + 1] = cpu_to_be32(j);
+                matrix[idx + 2] = cpu_to_be32(numa_info[i].distance[j]);
+            }
+        }
+
+        qemu_fdt_add_subnode(fdt, "/distance-map");
+        qemu_fdt_setprop_string(fdt, "/distance-map", "compatible",
+                                "numa-distance-map-v1");
+        qemu_fdt_setprop(fdt, "/distance-map", "distance-matrix",
+                         matrix, size);
+        g_free(matrix);
+    }
 }
 
 static void fdt_add_psci_node(const VirtMachineState *vms)
Signature · 1 line
Shannon
Reviewed-by on v1 1/2
#3 lore raw

Re: [Qemu-arm] [PATCH 1/2] hw/arm/virt-acpi-build: build SLIT when needed

In reply to Andrew Jones
Quoted 2 lines · Andrew Jones
Quoted 20 lines
---
 hw/arm/virt-acpi-build.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/arm/virt-acpi-build.c +4 -0
index e5852067f5bd..2079828c22a4 100644
@@ -776,6 +776,10 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
     if (nb_numa_nodes > 0) {
         acpi_add_table(table_offsets, tables_blob);
         build_srat(tables_blob, tables->linker, vms);
+        if (have_numa_distance) {
+            acpi_add_table(table_offsets, tables_blob);
+            build_slit(tables_blob, tables->linker);
+        }
     }
 
     if (its_class_name() && !vmc->no_its) {
Signature · 1 line
Shannon
#6 lore raw
In reply to Andrew Jones
Quoted 7 lines · Andrew Jones

Andrew Jones (2):
hw/arm/virt-acpi-build: build SLIT when needed hw/arm/virt: fdt: generate distance-map when needed

 hw/arm/virt-acpi-build.c |  4 ++++
 hw/arm/virt.c            | 21 +++++++++++++++++++++
 2 files changed, 25 insertions(+)

Applied to target-arm.next, thanks.

-- PMM