summaryrefslogtreecommitdiffstats
path: root/arch/x86/include/asm/summit
diff options
context:
space:
mode:
authorMike Travis <travis@sgi.com>2008-12-16 17:33:54 -0800
committerMike Travis <travis@sgi.com>2008-12-16 17:40:56 -0800
commit95d313cf1c1ecedc8bec5727b09bdacbf67dfc45 (patch)
treeee4aa8aff232bb30bb725c5670bb67d73484022d /arch/x86/include/asm/summit
parenta1681965011916c2f1f0f1f87e70784f5d5d5be5 (diff)
downloadblackbird-op-linux-95d313cf1c1ecedc8bec5727b09bdacbf67dfc45.tar.gz
blackbird-op-linux-95d313cf1c1ecedc8bec5727b09bdacbf67dfc45.zip
x86: Add cpu_mask_to_apicid_and
Impact: new API Add a helper function that takes two cpumask's, and's them and then returns the apicid of the result. This removes a need in io_apic.c that uses a temporary cpumask to hold (mask & cfg->domain). Signed-off-by: Mike Travis <travis@sgi.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'arch/x86/include/asm/summit')
-rw-r--r--arch/x86/include/asm/summit/apic.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/arch/x86/include/asm/summit/apic.h b/arch/x86/include/asm/summit/apic.h
index 437dc83725ca..cbcc2c7eb1d5 100644
--- a/arch/x86/include/asm/summit/apic.h
+++ b/arch/x86/include/asm/summit/apic.h
@@ -170,6 +170,45 @@ static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)
return apicid;
}
+static inline unsigned int cpu_mask_to_apicid_and(const cpumask_t *cpumask,
+ const cpumask_t *andmask)
+{
+ int num_bits_set;
+ int num_bits_set2;
+ int cpus_found = 0;
+ int cpu;
+ int apicid = 0;
+
+ num_bits_set = cpus_weight(*cpumask);
+ num_bits_set2 = cpus_weight(*andmask);
+ num_bits_set = min_t(int, num_bits_set, num_bits_set2);
+ /* Return id to all */
+ if (num_bits_set >= nr_cpu_ids)
+ return 0xFF;
+ /*
+ * The cpus in the mask must all be on the apic cluster. If are not
+ * on the same apicid cluster return default value of TARGET_CPUS.
+ */
+ while ((cpu = next_cpu(-1, *cpumask)) < nr_cpu_ids)
+ if (cpu_isset(cpu, *andmask)
+ apicid = cpu_to_logical_apicid(cpu);
+ while (cpus_found < num_bits_set) {
+ if (cpu_isset(cpu, *cpumask) && cpu_isset(cpu, *andmask)) {
+ int new_apicid = cpu_to_logical_apicid(cpu);
+ if (apicid_cluster(apicid) !=
+ apicid_cluster(new_apicid)) {
+ printk(KERN_WARNING
+ "%s: Not a valid mask!\n", __func__);
+ return 0xFF;
+ }
+ apicid = apicid | new_apicid;
+ cpus_found++;
+ }
+ cpu++;
+ }
+ return apicid;
+}
+
/* cpuid returns the value latched in the HW at reset, not the APIC ID
* register's value. For any box whose BIOS changes APIC IDs, like
* clustered APIC systems, we must use hard_smp_processor_id.
OpenPOWER on IntegriCloud