diff mbox series

[RFC,14/52] hw/smbios: Use generic topology name and helper

Message ID 20230213095035.158240-15-zhao1.liu@linux.intel.com
State New
Headers show
Series Introduce hybrid CPU topology | expand

Commit Message

Zhao Liu Feb. 13, 2023, 9:49 a.m. UTC
From: Zhao Liu <zhao1.liu@intel.com>

As the generic code, smbios should respect the different topologies: smp
or hybrid.

So rename smbios_smp_sockets to smbios_topo_sockets to decouple with smp
topology.

And use generic topology helpers to get topology information.

Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Ani Sinha <ani@anisinha.ca>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
 hw/smbios/smbios.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index cd4aa331cb3e..2ce1f2b1d94e 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -70,7 +70,8 @@  static SmbiosEntryPoint ep;
 static int smbios_type4_count = 0;
 static bool smbios_immutable;
 static bool smbios_have_defaults;
-static uint32_t smbios_cpuid_version, smbios_cpuid_features, smbios_smp_sockets;
+static uint32_t smbios_cpuid_version, smbios_cpuid_features;
+static uint32_t smbios_topo_sockets;
 
 static DECLARE_BITMAP(have_binfile_bitmap, SMBIOS_MAX_TYPE+1);
 static DECLARE_BITMAP(have_fields_bitmap, SMBIOS_MAX_TYPE+1);
@@ -461,7 +462,7 @@  opts_init(smbios_register_config);
 static void smbios_validate_table(MachineState *ms)
 {
     uint32_t expect_t4_count = smbios_legacy ?
-                                        ms->smp.cpus : smbios_smp_sockets;
+                               machine_topo_get_cpus(ms) : smbios_topo_sockets;
 
     if (smbios_type4_count && smbios_type4_count != expect_t4_count) {
         error_report("Expected %d SMBIOS Type 4 tables, got %d instead",
@@ -713,8 +714,8 @@  static void smbios_build_type_4_table(MachineState *ms, unsigned instance)
 {
     char sock_str[128];
     size_t tbl_len = SMBIOS_TYPE_4_LEN_V28;
-    unsigned cpus_per_socket = ms->smp.max_cpus / ms->smp.sockets;
-    unsigned cores_per_socket = cpus_per_socket / ms->smp.threads;
+    unsigned cpus_per_socket = machine_topo_get_threads_per_socket(ms);
+    unsigned cores_per_socket = machine_topo_get_cores_per_socket(ms);
 
     if (smbios_ep_type == SMBIOS_ENTRY_POINT_TYPE_64) {
         tbl_len = SMBIOS_TYPE_4_LEN_V30;
@@ -1088,10 +1089,10 @@  void smbios_get_tables(MachineState *ms,
         smbios_build_type_2_table();
         smbios_build_type_3_table();
 
-        smbios_smp_sockets = ms->smp.sockets;
-        assert(smbios_smp_sockets >= 1);
+        smbios_topo_sockets = machine_topo_get_sockets(ms);
+        assert(smbios_topo_sockets >= 1);
 
-        for (i = 0; i < smbios_smp_sockets; i++) {
+        for (i = 0; i < smbios_topo_sockets; i++) {
             smbios_build_type_4_table(ms, i);
         }