From: wanghongliang wanghongliang@loongson.cn
LoongArch inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IBENRY CVE: NA
--------------------------------
Signed-off-by: wanghongliang wanghongliang@loongson.cn --- arch/loongarch/include/asm/topology.h | 4 ++++ arch/loongarch/kernel/setup.c | 1 + arch/loongarch/kernel/smp.c | 3 +++ drivers/platform/loongarch/cpu_hwmon.c | 3 +-- 4 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/arch/loongarch/include/asm/topology.h b/arch/loongarch/include/asm/topology.h index 66128dec0bf6..379f5e4830eb 100644 --- a/arch/loongarch/include/asm/topology.h +++ b/arch/loongarch/include/asm/topology.h @@ -29,10 +29,14 @@ void numa_set_distance(int from, int to, int distance); #endif
#ifdef CONFIG_SMP +extern unsigned int __max_packages; +#define topology_max_packages() (__max_packages) #define topology_physical_package_id(cpu) (cpu_data[cpu].package) #define topology_core_id(cpu) (cpu_data[cpu].core) #define topology_core_cpumask(cpu) (&cpu_core_map[cpu]) #define topology_sibling_cpumask(cpu) (&cpu_sibling_map[cpu]) +#else +#define topology_max_packages() (1) #endif
#include <asm-generic/topology.h> diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c index 8362cbe9f102..415f16464214 100644 --- a/arch/loongarch/kernel/setup.c +++ b/arch/loongarch/kernel/setup.c @@ -135,6 +135,7 @@ static void __init parse_cpu_table(const struct dmi_header *dm)
loongson_sysconf.cpuname = (void *)dmi_string_parse(dm, dmi_data[16]); loongson_sysconf.cores_per_package = *(dmi_data + SMBIOS_THREAD_PACKAGE_OFFSET); + __max_packages++;
pr_info("CpuClock = %llu\n", cpu_clock_freq); } diff --git a/arch/loongarch/kernel/smp.c b/arch/loongarch/kernel/smp.c index d4717fc9e1db..5d02bf5126b7 100644 --- a/arch/loongarch/kernel/smp.c +++ b/arch/loongarch/kernel/smp.c @@ -74,6 +74,9 @@ static const char *ipi_types[NR_IPI] __tracepoint_string = { [IPI_CLEAR_VECTOR] = "Clear vector interrupts", };
+unsigned int __max_packages __read_mostly; +EXPORT_SYMBOL(__max_packages); + void show_ipi_list(struct seq_file *p, int prec) { unsigned int cpu, i; diff --git a/drivers/platform/loongarch/cpu_hwmon.c b/drivers/platform/loongarch/cpu_hwmon.c index 93a05993745a..57e771f39781 100644 --- a/drivers/platform/loongarch/cpu_hwmon.c +++ b/drivers/platform/loongarch/cpu_hwmon.c @@ -154,8 +154,7 @@ static int __init loongson_hwmon_init(void)
pr_info("Loongson Hwmon Enter...\n");
- nr_packages = loongson_sysconf.nr_cpus / - loongson_sysconf.cores_per_package; + nr_packages = topology_max_packages();
cpu_hwmon_dev = hwmon_device_register_with_groups(NULL, "cpu_hwmon", NULL, cpu_hwmon_groups);