]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/x86/include/asm/es7000/apic.h
x86: Add cpu_mask_to_apicid_and
[linux-2.6-omap-h63xx.git] / arch / x86 / include / asm / es7000 / apic.h
index 4cac0837bb4023acaaae8a83c02ebbd567686fb7..c2bed772af887cb43f52cb50d3805bcf387bac42 100644 (file)
@@ -214,6 +214,53 @@ 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)
+#if defined CONFIG_ES7000_CLUSTERED_APIC
+               return 0xFF;
+#else
+               return cpu_to_logical_apicid(0);
+#endif
+       /*
+        * 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__);
+#if defined CONFIG_ES7000_CLUSTERED_APIC
+                               return 0xFF;
+#else
+                               return cpu_to_logical_apicid(0);
+#endif
+                       }
+                       apicid = new_apicid;
+                       cpus_found++;
+               }
+               cpu++;
+       }
+       return apicid;
+}
+
 static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
 {
        return cpuid_apic >> index_msb;