MIPS: Support CPU topology files in sysfs
This patch is prepared for Loongson's NUMA support, it offer meaningful sysfs files such as physical_package_id, core_id, core_siblings and thread_siblings in /sys/devices/system/cpu/cpu?/topology. Signed-off-by: Huacai Chen <chenhc@lemote.com> Reviewed-by: Andreas Herrmann <andreas.herrmann@caviumnetworks.com> Cc: John Crispin <john@phrozen.org> Cc: Steven J. Hill <Steven.Hill@imgtec.com> Cc: Aurelien Jarno <aurelien@aurel32.net> Cc: linux-mips@linux-mips.org Cc: Fuxin Zhang <zhangfx@lemote.com> Cc: Zhangjin Wu <wuzhangjin@gmail.com> Patchwork: https://patchwork.linux-mips.org/patch/7184/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:

committed by
Ralf Baechle

parent
0f3f506b27
commit
bda4584cd9
@@ -59,9 +59,16 @@ EXPORT_SYMBOL(smp_num_siblings);
|
||||
cpumask_t cpu_sibling_map[NR_CPUS] __read_mostly;
|
||||
EXPORT_SYMBOL(cpu_sibling_map);
|
||||
|
||||
/* representing the core map of multi-core chips of each logical CPU */
|
||||
cpumask_t cpu_core_map[NR_CPUS] __read_mostly;
|
||||
EXPORT_SYMBOL(cpu_core_map);
|
||||
|
||||
/* representing cpus for which sibling maps can be computed */
|
||||
static cpumask_t cpu_sibling_setup_map;
|
||||
|
||||
/* representing cpus for which core maps can be computed */
|
||||
static cpumask_t cpu_core_setup_map;
|
||||
|
||||
cpumask_t cpu_coherent_mask;
|
||||
|
||||
static inline void set_cpu_sibling_map(int cpu)
|
||||
@@ -72,7 +79,8 @@ static inline void set_cpu_sibling_map(int cpu)
|
||||
|
||||
if (smp_num_siblings > 1) {
|
||||
for_each_cpu_mask(i, cpu_sibling_setup_map) {
|
||||
if (cpu_data[cpu].core == cpu_data[i].core) {
|
||||
if (cpu_data[cpu].package == cpu_data[i].package &&
|
||||
cpu_data[cpu].core == cpu_data[i].core) {
|
||||
cpu_set(i, cpu_sibling_map[cpu]);
|
||||
cpu_set(cpu, cpu_sibling_map[i]);
|
||||
}
|
||||
@@ -81,6 +89,20 @@ static inline void set_cpu_sibling_map(int cpu)
|
||||
cpu_set(cpu, cpu_sibling_map[cpu]);
|
||||
}
|
||||
|
||||
static inline void set_cpu_core_map(int cpu)
|
||||
{
|
||||
int i;
|
||||
|
||||
cpu_set(cpu, cpu_core_setup_map);
|
||||
|
||||
for_each_cpu_mask(i, cpu_core_setup_map) {
|
||||
if (cpu_data[cpu].package == cpu_data[i].package) {
|
||||
cpu_set(i, cpu_core_map[cpu]);
|
||||
cpu_set(cpu, cpu_core_map[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct plat_smp_ops *mp_ops;
|
||||
EXPORT_SYMBOL(mp_ops);
|
||||
|
||||
@@ -122,6 +144,7 @@ asmlinkage void start_secondary(void)
|
||||
set_cpu_online(cpu, true);
|
||||
|
||||
set_cpu_sibling_map(cpu);
|
||||
set_cpu_core_map(cpu);
|
||||
|
||||
cpu_set(cpu, cpu_callin_map);
|
||||
|
||||
@@ -175,6 +198,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
|
||||
current_thread_info()->cpu = 0;
|
||||
mp_ops->prepare_cpus(max_cpus);
|
||||
set_cpu_sibling_map(0);
|
||||
set_cpu_core_map(0);
|
||||
#ifndef CONFIG_HOTPLUG_CPU
|
||||
init_cpu_present(cpu_possible_mask);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user