qemu-arm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/2] hw/arm/sbsa-ref: Add cpu-map to device tree


From: Marcin Juszkiewicz
Subject: Re: [PATCH 2/2] hw/arm/sbsa-ref: Add cpu-map to device tree
Date: Fri, 29 Dec 2023 12:58:30 +0100
User-agent: Mozilla Thunderbird

W dniu 27.12.2023 o 13:07, Xiong Yining pisze:
From: xiongyining1480 <xiongyining1480@phytium.com.cn>

Support CPU topology description through device tree.

Signed-off-by: Xiong Yining <xiongyining1480@phytium.com.cn>
Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn>
---
  hw/arm/sbsa-ref.c | 35 +++++++++++++++++++++++++++++++++++
  1 file changed, 35 insertions(+)

diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
index e6cd612bc5..a3c851148a 100644
--- a/hw/arm/sbsa-ref.c
+++ b/hw/arm/sbsa-ref.c
@@ -283,10 +283,45 @@ static void create_fdt(SBSAMachineState *sms)
                  ms->possible_cpus->cpus[cs->cpu_index].props.node_id);
          }
+ qemu_fdt_setprop_cell(sms->fdt, nodename, "phandle",
+                        qemu_fdt_alloc_phandle(sms->fdt));
+
          g_free(nodename);
      }
+
      sbsa_fdt_add_gic_node(sms);

Can you add vCPU topology code before ^^ line? So code would add /cpus/ node and then go for /intc/ node.

+
+    /*
+     * Add vCPU topology description through fdt node cpu-map.

Maybe worth adding pointer to hw/arm/virt.c code for longer description?

+     */
+    qemu_fdt_add_subnode(sms->fdt, "/cpus/cpu-map");
+
+    for (cpu = sms->smp_cpus - 1; cpu >= 0; cpu--) {
+        char *cpu_path = g_strdup_printf("/cpus/cpu@%d", cpu);
+        char *map_path;
+
+        if (ms->smp.threads > 1) {
+            map_path = g_strdup_printf(
+                "/cpus/cpu-map/socket%d/cluster%d/core%d/thread%d",
+                cpu / (ms->smp.clusters * ms->smp.cores * ms->smp.threads),
+                (cpu / (ms->smp.cores * ms->smp.threads)) % ms->smp.clusters,
+                (cpu / ms->smp.threads) % ms->smp.cores,
+                cpu % ms->smp.threads);
+        } else {
+            map_path = g_strdup_printf(
+                "/cpus/cpu-map/socket%d/cluster%d/core%d",
+                cpu / (ms->smp.clusters * ms->smp.cores),
+                (cpu / ms->smp.cores) % ms->smp.clusters,
+                cpu % ms->smp.cores);
+        }
+        qemu_fdt_add_path(sms->fdt, map_path);
+        qemu_fdt_setprop_phandle(sms->fdt, map_path, "cpu", cpu_path);
+
+        g_free(map_path);
+        g_free(cpu_path);
+    }
+
  }
#define SBSA_FLASH_SECTOR_SIZE (256 * KiB)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]