hw/arm/virt: Support cluster level in DT cpu-map

Support one cluster level between core and physical package in the
cpu-map of Arm/virt devicetree. This is also consistent with Linux
Doc "Documentation/devicetree/bindings/cpu/cpu-topology.txt".

Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Message-id: 20220107083232.16256-3-wangyanan55@huawei.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Yanan Wang 2022-01-07 16:32:28 +08:00 committed by Peter Maydell
parent d55c316f91
commit 28a60a59c0
1 changed files with 8 additions and 7 deletions

View File

@ -434,9 +434,8 @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
* can contain several layers of clustering within a single physical * can contain several layers of clustering within a single physical
* package and cluster nodes can be contained in parent cluster nodes. * package and cluster nodes can be contained in parent cluster nodes.
* *
* Given that cluster is not yet supported in the vCPU topology, * Note: currently we only support one layer of clustering within
* we currently generate one cluster node within each socket node * each physical package.
* by default.
*/ */
qemu_fdt_add_subnode(ms->fdt, "/cpus/cpu-map"); qemu_fdt_add_subnode(ms->fdt, "/cpus/cpu-map");
@ -446,14 +445,16 @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
if (ms->smp.threads > 1) { if (ms->smp.threads > 1) {
map_path = g_strdup_printf( map_path = g_strdup_printf(
"/cpus/cpu-map/socket%d/cluster0/core%d/thread%d", "/cpus/cpu-map/socket%d/cluster%d/core%d/thread%d",
cpu / (ms->smp.cores * ms->smp.threads), 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) % ms->smp.cores,
cpu % ms->smp.threads); cpu % ms->smp.threads);
} else { } else {
map_path = g_strdup_printf( map_path = g_strdup_printf(
"/cpus/cpu-map/socket%d/cluster0/core%d", "/cpus/cpu-map/socket%d/cluster%d/core%d",
cpu / ms->smp.cores, cpu / (ms->smp.clusters * ms->smp.cores),
(cpu / ms->smp.cores) % ms->smp.clusters,
cpu % ms->smp.cores); cpu % ms->smp.cores);
} }
qemu_fdt_add_path(ms->fdt, map_path); qemu_fdt_add_path(ms->fdt, map_path);