|
|
586cba |
From 8a12049e97149056f61f7748d9869606d282d16e Mon Sep 17 00:00:00 2001
|
|
|
586cba |
From: Gavin Shan <gshan@redhat.com>
|
|
|
586cba |
Date: Wed, 11 May 2022 18:01:35 +0800
|
|
|
586cba |
Subject: [PATCH 06/16] hw/acpi/aml-build: Use existing CPU topology to build
|
|
|
586cba |
PPTT table
|
|
|
586cba |
|
|
|
586cba |
RH-Author: Gavin Shan <gshan@redhat.com>
|
|
|
586cba |
RH-MergeRequest: 86: hw/arm/virt: Fix the default CPU topology
|
|
|
586cba |
RH-Commit: [6/6] 53fa376531c204cf706cc1a7a0499019756106cb (gwshan/qemu-rhel-9)
|
|
|
586cba |
RH-Bugzilla: 2041823
|
|
|
586cba |
RH-Acked-by: Eric Auger <eric.auger@redhat.com>
|
|
|
586cba |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
586cba |
RH-Acked-by: Andrew Jones <drjones@redhat.com>
|
|
|
586cba |
|
|
|
586cba |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2041823
|
|
|
586cba |
|
|
|
586cba |
When the PPTT table is built, the CPU topology is re-calculated, but
|
|
|
586cba |
it's unecessary because the CPU topology has been populated in
|
|
|
586cba |
virt_possible_cpu_arch_ids() on arm/virt machine.
|
|
|
586cba |
|
|
|
586cba |
This reworks build_pptt() to avoid by reusing the existing IDs in
|
|
|
586cba |
ms->possible_cpus. Currently, the only user of build_pptt() is
|
|
|
586cba |
arm/virt machine.
|
|
|
586cba |
|
|
|
586cba |
Signed-off-by: Gavin Shan <gshan@redhat.com>
|
|
|
586cba |
Tested-by: Yanan Wang <wangyanan55@huawei.com>
|
|
|
586cba |
Reviewed-by: Yanan Wang <wangyanan55@huawei.com>
|
|
|
586cba |
Acked-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
586cba |
Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
586cba |
Message-id: 20220503140304.855514-7-gshan@redhat.com
|
|
|
586cba |
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
|
|
586cba |
(cherry picked from commit ae9141d4a3265553503bf07d3574b40f84615a34)
|
|
|
586cba |
Signed-off-by: Gavin Shan <gshan@redhat.com>
|
|
|
586cba |
---
|
|
|
586cba |
hw/acpi/aml-build.c | 111 +++++++++++++++++++-------------------------
|
|
|
586cba |
1 file changed, 48 insertions(+), 63 deletions(-)
|
|
|
586cba |
|
|
|
586cba |
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
|
|
|
586cba |
index 4086879ebf..e6bfac95c7 100644
|
|
|
586cba |
--- a/hw/acpi/aml-build.c
|
|
|
586cba |
+++ b/hw/acpi/aml-build.c
|
|
|
586cba |
@@ -2002,86 +2002,71 @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
|
|
|
586cba |
const char *oem_id, const char *oem_table_id)
|
|
|
586cba |
{
|
|
|
586cba |
MachineClass *mc = MACHINE_GET_CLASS(ms);
|
|
|
586cba |
- GQueue *list = g_queue_new();
|
|
|
586cba |
- guint pptt_start = table_data->len;
|
|
|
586cba |
- guint parent_offset;
|
|
|
586cba |
- guint length, i;
|
|
|
586cba |
- int uid = 0;
|
|
|
586cba |
- int socket;
|
|
|
586cba |
+ CPUArchIdList *cpus = ms->possible_cpus;
|
|
|
586cba |
+ int64_t socket_id = -1, cluster_id = -1, core_id = -1;
|
|
|
586cba |
+ uint32_t socket_offset = 0, cluster_offset = 0, core_offset = 0;
|
|
|
586cba |
+ uint32_t pptt_start = table_data->len;
|
|
|
586cba |
+ int n;
|
|
|
586cba |
AcpiTable table = { .sig = "PPTT", .rev = 2,
|
|
|
586cba |
.oem_id = oem_id, .oem_table_id = oem_table_id };
|
|
|
586cba |
|
|
|
586cba |
acpi_table_begin(&table, table_data);
|
|
|
586cba |
|
|
|
586cba |
- for (socket = 0; socket < ms->smp.sockets; socket++) {
|
|
|
586cba |
- g_queue_push_tail(list,
|
|
|
586cba |
- GUINT_TO_POINTER(table_data->len - pptt_start));
|
|
|
586cba |
- build_processor_hierarchy_node(
|
|
|
586cba |
- table_data,
|
|
|
586cba |
- /*
|
|
|
586cba |
- * Physical package - represents the boundary
|
|
|
586cba |
- * of a physical package
|
|
|
586cba |
- */
|
|
|
586cba |
- (1 << 0),
|
|
|
586cba |
- 0, socket, NULL, 0);
|
|
|
586cba |
- }
|
|
|
586cba |
-
|
|
|
586cba |
- if (mc->smp_props.clusters_supported) {
|
|
|
586cba |
- length = g_queue_get_length(list);
|
|
|
586cba |
- for (i = 0; i < length; i++) {
|
|
|
586cba |
- int cluster;
|
|
|
586cba |
-
|
|
|
586cba |
- parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list));
|
|
|
586cba |
- for (cluster = 0; cluster < ms->smp.clusters; cluster++) {
|
|
|
586cba |
- g_queue_push_tail(list,
|
|
|
586cba |
- GUINT_TO_POINTER(table_data->len - pptt_start));
|
|
|
586cba |
- build_processor_hierarchy_node(
|
|
|
586cba |
- table_data,
|
|
|
586cba |
- (0 << 0), /* not a physical package */
|
|
|
586cba |
- parent_offset, cluster, NULL, 0);
|
|
|
586cba |
- }
|
|
|
586cba |
+ /*
|
|
|
586cba |
+ * This works with the assumption that cpus[n].props.*_id has been
|
|
|
586cba |
+ * sorted from top to down levels in mc->possible_cpu_arch_ids().
|
|
|
586cba |
+ * Otherwise, the unexpected and duplicated containers will be
|
|
|
586cba |
+ * created.
|
|
|
586cba |
+ */
|
|
|
586cba |
+ for (n = 0; n < cpus->len; n++) {
|
|
|
586cba |
+ if (cpus->cpus[n].props.socket_id != socket_id) {
|
|
|
586cba |
+ assert(cpus->cpus[n].props.socket_id > socket_id);
|
|
|
586cba |
+ socket_id = cpus->cpus[n].props.socket_id;
|
|
|
586cba |
+ cluster_id = -1;
|
|
|
586cba |
+ core_id = -1;
|
|
|
586cba |
+ socket_offset = table_data->len - pptt_start;
|
|
|
586cba |
+ build_processor_hierarchy_node(table_data,
|
|
|
586cba |
+ (1 << 0), /* Physical package */
|
|
|
586cba |
+ 0, socket_id, NULL, 0);
|
|
|
586cba |
}
|
|
|
586cba |
- }
|
|
|
586cba |
|
|
|
586cba |
- length = g_queue_get_length(list);
|
|
|
586cba |
- for (i = 0; i < length; i++) {
|
|
|
586cba |
- int core;
|
|
|
586cba |
-
|
|
|
586cba |
- parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list));
|
|
|
586cba |
- for (core = 0; core < ms->smp.cores; core++) {
|
|
|
586cba |
- if (ms->smp.threads > 1) {
|
|
|
586cba |
- g_queue_push_tail(list,
|
|
|
586cba |
- GUINT_TO_POINTER(table_data->len - pptt_start));
|
|
|
586cba |
- build_processor_hierarchy_node(
|
|
|
586cba |
- table_data,
|
|
|
586cba |
- (0 << 0), /* not a physical package */
|
|
|
586cba |
- parent_offset, core, NULL, 0);
|
|
|
586cba |
- } else {
|
|
|
586cba |
- build_processor_hierarchy_node(
|
|
|
586cba |
- table_data,
|
|
|
586cba |
- (1 << 1) | /* ACPI Processor ID valid */
|
|
|
586cba |
- (1 << 3), /* Node is a Leaf */
|
|
|
586cba |
- parent_offset, uid++, NULL, 0);
|
|
|
586cba |
+ if (mc->smp_props.clusters_supported) {
|
|
|
586cba |
+ if (cpus->cpus[n].props.cluster_id != cluster_id) {
|
|
|
586cba |
+ assert(cpus->cpus[n].props.cluster_id > cluster_id);
|
|
|
586cba |
+ cluster_id = cpus->cpus[n].props.cluster_id;
|
|
|
586cba |
+ core_id = -1;
|
|
|
586cba |
+ cluster_offset = table_data->len - pptt_start;
|
|
|
586cba |
+ build_processor_hierarchy_node(table_data,
|
|
|
586cba |
+ (0 << 0), /* Not a physical package */
|
|
|
586cba |
+ socket_offset, cluster_id, NULL, 0);
|
|
|
586cba |
}
|
|
|
586cba |
+ } else {
|
|
|
586cba |
+ cluster_offset = socket_offset;
|
|
|
586cba |
}
|
|
|
586cba |
- }
|
|
|
586cba |
|
|
|
586cba |
- length = g_queue_get_length(list);
|
|
|
586cba |
- for (i = 0; i < length; i++) {
|
|
|
586cba |
- int thread;
|
|
|
586cba |
+ if (ms->smp.threads == 1) {
|
|
|
586cba |
+ build_processor_hierarchy_node(table_data,
|
|
|
586cba |
+ (1 << 1) | /* ACPI Processor ID valid */
|
|
|
586cba |
+ (1 << 3), /* Node is a Leaf */
|
|
|
586cba |
+ cluster_offset, n, NULL, 0);
|
|
|
586cba |
+ } else {
|
|
|
586cba |
+ if (cpus->cpus[n].props.core_id != core_id) {
|
|
|
586cba |
+ assert(cpus->cpus[n].props.core_id > core_id);
|
|
|
586cba |
+ core_id = cpus->cpus[n].props.core_id;
|
|
|
586cba |
+ core_offset = table_data->len - pptt_start;
|
|
|
586cba |
+ build_processor_hierarchy_node(table_data,
|
|
|
586cba |
+ (0 << 0), /* Not a physical package */
|
|
|
586cba |
+ cluster_offset, core_id, NULL, 0);
|
|
|
586cba |
+ }
|
|
|
586cba |
|
|
|
586cba |
- parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list));
|
|
|
586cba |
- for (thread = 0; thread < ms->smp.threads; thread++) {
|
|
|
586cba |
- build_processor_hierarchy_node(
|
|
|
586cba |
- table_data,
|
|
|
586cba |
+ build_processor_hierarchy_node(table_data,
|
|
|
586cba |
(1 << 1) | /* ACPI Processor ID valid */
|
|
|
586cba |
(1 << 2) | /* Processor is a Thread */
|
|
|
586cba |
(1 << 3), /* Node is a Leaf */
|
|
|
586cba |
- parent_offset, uid++, NULL, 0);
|
|
|
586cba |
+ core_offset, n, NULL, 0);
|
|
|
586cba |
}
|
|
|
586cba |
}
|
|
|
586cba |
|
|
|
586cba |
- g_queue_free(list);
|
|
|
586cba |
acpi_table_end(linker, &table);
|
|
|
586cba |
}
|
|
|
586cba |
|
|
|
586cba |
--
|
|
|
586cba |
2.31.1
|
|
|
586cba |
|