summaryrefslogtreecommitdiffstats
path: root/arch/mips/kernel
diff options
context:
space:
mode:
authorPaul Burton <paul.burton@imgtec.com>2017-08-12 19:49:37 -0700
committerRalf Baechle <ralf@linux-mips.org>2017-08-30 00:57:27 +0200
commitfe7a38c625a2ee375870567c9fc8302e51e550f7 (patch)
tree116de1ad4eb37d1e5944c322c889505d5ac5e1e3 /arch/mips/kernel
parent856fbcee6099a292f62b9d23c946704f9ffe19f3 (diff)
downloadlinux-fe7a38c625a2ee375870567c9fc8302e51e550f7.tar.gz
linux-fe7a38c625a2ee375870567c9fc8302e51e550f7.tar.bz2
linux-fe7a38c625a2ee375870567c9fc8302e51e550f7.zip
MIPS: Unify checks for sibling CPUs
Up until now we have open-coded checks for whether CPUs are siblings, with slight variations on whether we consider the package ID or not. This will only get more complex when we introduce cluster support, so in preparation for that this patch introduces a cpus_are_siblings() function which can be used to check whether or not 2 CPUs are siblings in a consistent manner. By checking globalnumber with the VP ID masked out this also has the neat side effect of being ready for multi-cluster systems already. Signed-off-by: Paul Burton <paul.burton@imgtec.com> Acked-by: Rafael J. Wysocki <rjw@rjwysocki.net> Acked-by: Thomas Gleixner <tglx@linutronix.de> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/17011/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel')
-rw-r--r--arch/mips/kernel/smp-cps.c8
-rw-r--r--arch/mips/kernel/smp.c12
2 files changed, 9 insertions, 11 deletions
diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c
index 699459ed293b..8cc508809466 100644
--- a/arch/mips/kernel/smp-cps.c
+++ b/arch/mips/kernel/smp-cps.c
@@ -147,7 +147,7 @@ static void __init cps_prepare_cpus(unsigned int max_cpus)
cpu_has_dc_aliases ? "dcache aliasing" : "");
for_each_present_cpu(c) {
- if (cpu_core(&cpu_data[c]))
+ if (!cpus_are_siblings(smp_processor_id(), c))
set_cpu_present(c, false);
}
}
@@ -319,10 +319,10 @@ static void cps_boot_secondary(int cpu, struct task_struct *idle)
mips_cm_unlock_other();
}
- if (core != cpu_core(&current_cpu_data)) {
+ if (!cpus_are_siblings(cpu, smp_processor_id())) {
/* Boot a VPE on another powered up core */
for (remote = 0; remote < NR_CPUS; remote++) {
- if (cpu_core(&cpu_data[remote]) != core)
+ if (!cpus_are_siblings(cpu, remote))
continue;
if (cpu_online(remote))
break;
@@ -431,7 +431,7 @@ void play_dead(void)
/* Look for another online VPE within the core */
for_each_online_cpu(cpu_death_sibling) {
- if (cpu_core(&cpu_data[cpu_death_sibling]) != core)
+ if (!cpus_are_siblings(cpu, cpu_death_sibling))
continue;
/*
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index a54e5857c227..4cc43892b959 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -96,8 +96,7 @@ static inline void set_cpu_sibling_map(int cpu)
if (smp_num_siblings > 1) {
for_each_cpu(i, &cpu_sibling_setup_map) {
- if (cpu_data[cpu].package == cpu_data[i].package &&
- cpu_core(&cpu_data[cpu]) == cpu_core(&cpu_data[i])) {
+ if (cpus_are_siblings(cpu, i)) {
cpumask_set_cpu(i, &cpu_sibling_map[cpu]);
cpumask_set_cpu(cpu, &cpu_sibling_map[i]);
}
@@ -134,8 +133,7 @@ void calculate_cpu_foreign_map(void)
for_each_online_cpu(i) {
core_present = 0;
for_each_cpu(k, &temp_foreign_map)
- if (cpu_data[i].package == cpu_data[k].package &&
- cpu_core(&cpu_data[i]) == cpu_core(&cpu_data[k]))
+ if (cpus_are_siblings(i, k))
core_present = 1;
if (!core_present)
cpumask_set_cpu(i, &temp_foreign_map);
@@ -186,11 +184,11 @@ void mips_smp_send_ipi_mask(const struct cpumask *mask, unsigned int action)
if (mips_cpc_present()) {
for_each_cpu(cpu, mask) {
- core = cpu_core(&cpu_data[cpu]);
-
- if (core == cpu_core(&current_cpu_data))
+ if (cpus_are_siblings(cpu, smp_processor_id()))
continue;
+ core = cpu_core(&cpu_data[cpu]);
+
while (!cpumask_test_cpu(cpu, &cpu_coherent_mask)) {
mips_cm_lock_other(core, 0);
mips_cpc_lock_other(core);