Skip to content

Commit 1de0ae2

Browse files
JohnsPonychenhuacai
authored andcommitted
LoongArch: Correct the calculation logic of thread_count
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>
1 parent a258a3c commit 1de0ae2

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

arch/loongarch/kernel/setup.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#define SMBIOS_FREQLOW_MASK 0xFF
5757
#define SMBIOS_CORE_PACKAGE_OFFSET 0x23
5858
#define SMBIOS_THREAD_PACKAGE_OFFSET 0x25
59+
#define SMBIOS_THREAD_PACKAGE_2_OFFSET 0x2E
5960
#define LOONGSON_EFI_ENABLE (1 << 3)
6061

6162
unsigned long fw_arg0, fw_arg1, fw_arg2;
@@ -126,7 +127,12 @@ static void __init parse_cpu_table(const struct dmi_header *dm)
126127
cpu_clock_freq = freq_temp * 1000000;
127128

128129
loongson_sysconf.cpuname = (void *)dmi_string_parse(dm, dmi_data[16]);
129-
loongson_sysconf.cores_per_package = *(dmi_data + SMBIOS_THREAD_PACKAGE_OFFSET);
130+
loongson_sysconf.cores_per_package = *(u8 *)(dmi_data + SMBIOS_THREAD_PACKAGE_OFFSET);
131+
if (dm->length >= 0x30 && loongson_sysconf.cores_per_package == 0xff) {
132+
/* SMBIOS 3.0+ has ThreadCount2 for more than 255 threads */
133+
loongson_sysconf.cores_per_package =
134+
*(u16 *)(dmi_data + SMBIOS_THREAD_PACKAGE_2_OFFSET);
135+
}
130136

131137
pr_info("CpuClock = %llu\n", cpu_clock_freq);
132138
}

0 commit comments

Comments
 (0)