]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/x86/include/asm/summit/apic.h
x86, apic: clean up target_cpus methods
[linux-2.6-omap-h63xx.git] / arch / x86 / include / asm / summit / apic.h
index 99327d1be49f0bd0fed4ecd5ca189af6bde63188..7c1f9151429cb78aa4522947d252d1a0931435b1 100644 (file)
@@ -2,6 +2,7 @@
 #define __ASM_SUMMIT_APIC_H
 
 #include <asm/smp.h>
+#include <linux/gfp.h>
 
 #define esr_disable (1)
 #define NO_BALANCE_IRQ (0)
@@ -14,7 +15,7 @@
 
 #define APIC_DFR_VALUE (APIC_DFR_CLUSTER)
 
-static inline const cpumask_t *target_cpus(void)
+static inline const cpumask_t *summit_target_cpus(void)
 {
        /* CPU_MASK_ALL (0xff) has undefined behaviour with
         * dest_LowestPrio mode logical clustered apic interrupt routing
@@ -23,9 +24,6 @@ static inline const cpumask_t *target_cpus(void)
        return &cpumask_of_cpu(0);
 }
 
-#define INT_DELIVERY_MODE (dest_LowestPrio)
-#define INT_DEST_MODE 1     /* logical delivery broadcast to all procs */
-
 static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
 {
        return 0;
@@ -52,7 +50,7 @@ static inline void init_apic_ldr(void)
        int i;
 
        /* Create logical APIC IDs by counting CPUs already in cluster. */
-       for (count = 0, i = NR_CPUS; --i >= 0; ) {
+       for (count = 0, i = nr_cpu_ids; --i >= 0; ) {
                lid = cpu_2_logical_apicid[i];
                if (lid != BAD_APICID && apicid_cluster(lid) == my_cluster)
                        ++count;
@@ -73,7 +71,7 @@ static inline int multi_timer_check(int apic, int irq)
        return 0;
 }
 
-static inline int apic_id_registered(void)
+static inline int summit_apic_id_registered(void)
 {
        return 1;
 }
@@ -97,8 +95,8 @@ static inline int apicid_to_node(int logical_apicid)
 static inline int cpu_to_logical_apicid(int cpu)
 {
 #ifdef CONFIG_SMP
-       if (cpu >= NR_CPUS)
-              return BAD_APICID;
+       if (cpu >= nr_cpu_ids)
+               return BAD_APICID;
        return (int)cpu_2_logical_apicid[cpu];
 #else
        return logical_smp_processor_id();
@@ -107,7 +105,7 @@ static inline int cpu_to_logical_apicid(int cpu)
 
 static inline int cpu_present_to_apicid(int mps_cpu)
 {
-       if (mps_cpu < NR_CPUS)
+       if (mps_cpu < nr_cpu_ids)
                return (int)per_cpu(x86_bios_cpu_apicid, mps_cpu);
        else
                return BAD_APICID;
@@ -146,7 +144,7 @@ static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)
 
        num_bits_set = cpus_weight(*cpumask);
        /* Return id to all */
-       if (num_bits_set == NR_CPUS)
+       if (num_bits_set >= nr_cpu_ids)
                return (int) 0xFF;
        /*
         * The cpus in the mask must all be on the apic cluster.  If are not
@@ -173,42 +171,16 @@ static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)
 static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *inmask,
                                                  const struct cpumask *andmask)
 {
-       int num_bits_set;
-       int cpus_found = 0;
-       int cpu;
-       int apicid = 0xFF;
+       int apicid = cpu_to_logical_apicid(0);
        cpumask_var_t cpumask;
 
        if (!alloc_cpumask_var(&cpumask, GFP_ATOMIC))
-               return (int) 0xFF;
+               return apicid;
 
        cpumask_and(cpumask, inmask, andmask);
        cpumask_and(cpumask, cpumask, cpu_online_mask);
+       apicid = cpu_mask_to_apicid(cpumask);
 
-       num_bits_set = cpumask_weight(cpumask);
-       /* Return id to all */
-       if (num_bits_set == nr_cpu_ids)
-               goto exit;
-       /*
-        * 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.
-        */
-       cpu = cpumask_first(cpumask);
-       apicid = cpu_to_logical_apicid(cpu);
-       while (cpus_found < num_bits_set) {
-               if (cpumask_test_cpu(cpu, cpumask)) {
-                       int new_apicid = cpu_to_logical_apicid(cpu);
-                       if (apicid_cluster(apicid) !=
-                                       apicid_cluster(new_apicid)){
-                               printk ("%s: Not a valid mask!\n", __func__);
-                               return 0xFF;
-                       }
-                       apicid = apicid | new_apicid;
-                       cpus_found++;
-               }
-               cpu++;
-       }
-exit:
        free_cpumask_var(cpumask);
        return apicid;
 }