]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
LoongArch: Correct the calculation logic of thread_count
authorQiang Ma <maqianga@uniontech.com>
Sat, 6 Dec 2025 02:39:49 +0000 (10:39 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Sat, 6 Dec 2025 02:39:49 +0000 (10:39 +0800)
For thread_count, the current calculation method has a maximum of 255,
which may not be sufficient in the future. Therefore, we are correcting
it now.

Reference: SMBIOS Specification, 7.5 Processor Information (Type 4)[1]

[1]: https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.9.0.pdf

Cc: stable@vger.kernel.org
Signed-off-by: Qiang Ma <maqianga@uniontech.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/kernel/setup.c

index 25a87378e48e43d7d9d121f7371010758b032a13..20cb6f30645683d322006208bdd093e82095a9f8 100644 (file)
@@ -56,6 +56,7 @@
 #define SMBIOS_FREQLOW_MASK            0xFF
 #define SMBIOS_CORE_PACKAGE_OFFSET     0x23
 #define SMBIOS_THREAD_PACKAGE_OFFSET   0x25
+#define SMBIOS_THREAD_PACKAGE_2_OFFSET 0x2E
 #define LOONGSON_EFI_ENABLE            (1 << 3)
 
 unsigned long fw_arg0, fw_arg1, fw_arg2;
@@ -126,7 +127,12 @@ 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_THREAD_PACKAGE_OFFSET);
+       loongson_sysconf.cores_per_package = *(u8 *)(dmi_data + SMBIOS_THREAD_PACKAGE_OFFSET);
+       if (dm->length >= 0x30 && loongson_sysconf.cores_per_package == 0xff) {
+               /* SMBIOS 3.0+ has ThreadCount2 for more than 255 threads */
+               loongson_sysconf.cores_per_package =
+                                         *(u16 *)(dmi_data + SMBIOS_THREAD_PACKAGE_2_OFFSET);
+       }
 
        pr_info("CpuClock = %llu\n", cpu_clock_freq);
 }