]> git.hungrycats.org Git - linux/commitdiff
LoongArch: Get correct cores_per_package for SMT systems
authorHuacai Chen <chenhuacai@loongson.cn>
Mon, 21 Oct 2024 14:11:18 +0000 (22:11 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Nov 2024 00:56:06 +0000 (01:56 +0100)
commit b7296f9d5bf99330063d4bbecc43c9b33fed0137 upstream.

In loongson_sysconf, The "core" of cores_per_node and cores_per_package
stands for a logical core, which means in a SMT system it stands for a
thread indeed. This information is gotten from SMBIOS Type4 Structure,
so in order to get a correct cores_per_package for both SMT and non-SMT
systems in parse_cpu_table() we should use SMBIOS_THREAD_PACKAGE_OFFSET
instead of SMBIOS_CORE_PACKAGE_OFFSET.

Cc: stable@vger.kernel.org
Reported-by: Chao Li <lichao@loongson.cn>
Tested-by: Chao Li <lichao@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/loongarch/include/asm/bootinfo.h
arch/loongarch/kernel/setup.c

index ed0910e8b856b8804c2d1027f44e74be8e23f620..e703615ca706c2e567d0be883bb0186617ea893c 100644 (file)
@@ -25,6 +25,10 @@ struct loongson_board_info {
        const char *board_vendor;
 };
 
+/*
+ * The "core" of cores_per_node and cores_per_package stands for a
+ * logical core, which means in a SMT system it stands for a thread.
+ */
 struct loongson_system_configuration {
        int nr_cpus;
        int nr_nodes;
index ae436def7ee98792d875317607fe6fe45ea33e84..b00e885d984584ff4db66d041163279aff445103 100644 (file)
@@ -49,6 +49,7 @@
 #define SMBIOS_FREQHIGH_OFFSET         0x17
 #define SMBIOS_FREQLOW_MASK            0xFF
 #define SMBIOS_CORE_PACKAGE_OFFSET     0x23
+#define SMBIOS_THREAD_PACKAGE_OFFSET   0x25
 #define LOONGSON_EFI_ENABLE            (1 << 3)
 
 struct screen_info screen_info __section(".data");
@@ -115,7 +116,7 @@ static void __init parse_cpu_table(const struct dmi_header *dm)
        cpu_clock_freq = freq_temp * 1000000;
 
        loongson_sysconf.cpuname = (void *)dmi_string_parse(dm, dmi_data[16]);
-       loongson_sysconf.cores_per_package = *(dmi_data + SMBIOS_CORE_PACKAGE_OFFSET);
+       loongson_sysconf.cores_per_package = *(dmi_data + SMBIOS_THREAD_PACKAGE_OFFSET);
 
        pr_info("CpuClock = %llu\n", cpu_clock_freq);
 }