Skip to content

Commit b7296f9

Browse files
committed
LoongArch: Get correct cores_per_package for SMT systems
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: [email protected] Reported-by: Chao Li <[email protected]> Tested-by: Chao Li <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent b69269c commit b7296f9

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

arch/loongarch/include/asm/bootinfo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ struct loongson_board_info {
2626

2727
#define NR_WORDS DIV_ROUND_UP(NR_CPUS, BITS_PER_LONG)
2828

29+
/*
30+
* The "core" of cores_per_node and cores_per_package stands for a
31+
* logical core, which means in a SMT system it stands for a thread.
32+
*/
2933
struct loongson_system_configuration {
3034
int nr_cpus;
3135
int nr_nodes;

arch/loongarch/kernel/setup.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#define SMBIOS_FREQHIGH_OFFSET 0x17
5656
#define SMBIOS_FREQLOW_MASK 0xFF
5757
#define SMBIOS_CORE_PACKAGE_OFFSET 0x23
58+
#define SMBIOS_THREAD_PACKAGE_OFFSET 0x25
5859
#define LOONGSON_EFI_ENABLE (1 << 3)
5960

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

127128
loongson_sysconf.cpuname = (void *)dmi_string_parse(dm, dmi_data[16]);
128-
loongson_sysconf.cores_per_package = *(dmi_data + SMBIOS_CORE_PACKAGE_OFFSET);
129+
loongson_sysconf.cores_per_package = *(dmi_data + SMBIOS_THREAD_PACKAGE_OFFSET);
129130

130131
pr_info("CpuClock = %llu\n", cpu_clock_freq);
131132
}

0 commit comments

Comments
 (0)