x86: clean up the APIC_DEST_LOGICAL logic
authorIngo Molnar <mingo@elte.hu>
Wed, 28 Jan 2009 04:13:04 +0000 (05:13 +0100)
committerIngo Molnar <mingo@elte.hu>
Wed, 28 Jan 2009 22:20:18 +0000 (23:20 +0100)
Impact: cleanup

The bigsmp and es7000 subarchitectures un-defined APIC_DEST_LOGICAL in
a rather nasty way by re-defining it to zero. That is infinitely
fragile and makes it very hard to see what to code really does in
a given context. The very same constant has different meanings and
values - depending on which subarch is enabled.

Untangle this mess by never undefining the constant, but instead
propagating the right values into the genapic driver templates.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
12 files changed:
arch/x86/include/asm/bigsmp/apic.h
arch/x86/include/asm/es7000/apic.h
arch/x86/include/asm/mach-generic/mach_apic.h
arch/x86/kernel/genapic_flat_64.c
arch/x86/kernel/genx2apic_cluster.c
arch/x86/kernel/genx2apic_phys.c
arch/x86/kernel/genx2apic_uv_x.c
arch/x86/kernel/io_apic.c
arch/x86/kernel/ipi.c
arch/x86/kernel/smpboot.c
arch/x86/mach-generic/bigsmp.c
arch/x86/mach-generic/es7000.c

index b550cb1110286fdad83565671fd5fd4c2871c96b..7e6e33a6db02459804bb1067e1389e71cf449aa2 100644 (file)
@@ -17,8 +17,6 @@ static inline const cpumask_t *bigsmp_target_cpus(void)
 #endif
 }
 
-#undef APIC_DEST_LOGICAL
-#define APIC_DEST_LOGICAL      0
 #define APIC_DFR_VALUE         (APIC_DFR_FLAT)
 #define NO_BALANCE_IRQ         (0)
 
index aa11c768bed7b63d83f6c1da20675269dfd56591..0d770fce4b2868754fc13c5dee91d83ebee323ed 100644 (file)
@@ -27,8 +27,6 @@ static inline const cpumask_t *es7000_target_cpus(void)
 
 #define APIC_DFR_VALUE         (APIC_DFR_FLAT)
 #define NO_BALANCE_IRQ         (0)
-#undef  APIC_DEST_LOGICAL
-#define APIC_DEST_LOGICAL      0x0
 
 static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
 {
index 63fe985219f9f7d4b9c52a6a839c3e055229ca32..00d5fe6e67698c71f9f3a22b32d71d73c70fec58 100644 (file)
@@ -4,8 +4,6 @@
 #include <asm/genapic.h>
 
 #define NO_BALANCE_IRQ (apic->no_balance_irq)
-#undef APIC_DEST_LOGICAL
-#define APIC_DEST_LOGICAL (apic->apic_destination_logical)
 #define init_apic_ldr (apic->init_apic_ldr)
 #define ioapic_phys_id_map (apic->ioapic_phys_id_map)
 #define setup_apic_routing (apic->setup_apic_routing)
index d437a60cc5896be03e69538753aa25bf71cf74fb..fd242c6b3ba1f9d0dd6179e39ec05b88fc47e459 100644 (file)
@@ -74,7 +74,7 @@ static inline void _flat_send_IPI_mask(unsigned long mask, int vector)
        unsigned long flags;
 
        local_irq_save(flags);
-       __send_IPI_dest_field(mask, vector, APIC_DEST_LOGICAL);
+       __send_IPI_dest_field(mask, vector, apic->apic_destination_logical);
        local_irq_restore(flags);
 }
 
@@ -114,7 +114,7 @@ static void flat_send_IPI_allbutself(int vector)
                        _flat_send_IPI_mask(mask, vector);
                }
        } else if (num_online_cpus() > 1) {
-               __send_IPI_shortcut(APIC_DEST_ALLBUT, vector,APIC_DEST_LOGICAL);
+               __send_IPI_shortcut(APIC_DEST_ALLBUT, vector, apic->apic_destination_logical);
        }
 }
 
@@ -123,7 +123,7 @@ static void flat_send_IPI_all(int vector)
        if (vector == NMI_VECTOR)
                flat_send_IPI_mask(cpu_online_mask, vector);
        else
-               __send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL);
+               __send_IPI_shortcut(APIC_DEST_ALLINC, vector, apic->apic_destination_logical);
 }
 
 static unsigned int get_apic_id(unsigned long x)
@@ -181,11 +181,11 @@ struct genapic apic_flat =  {
        .apic_id_registered             = flat_apic_id_registered,
 
        .irq_delivery_mode              = dest_LowestPrio,
-       .irq_dest_mode                  = (APIC_DEST_LOGICAL != 0),
+       .irq_dest_mode                  = 1, /* logical */
 
        .target_cpus                    = flat_target_cpus,
        .disable_esr                    = 0,
-       .apic_destination_logical       = 0,
+       .apic_destination_logical       = APIC_DEST_LOGICAL,
        .check_apicid_used              = NULL,
        .check_apicid_present           = NULL,
 
@@ -327,7 +327,7 @@ struct genapic apic_physflat =  {
        .apic_id_registered             = flat_apic_id_registered,
 
        .irq_delivery_mode              = dest_Fixed,
-       .irq_dest_mode                  = (APIC_DEST_PHYSICAL != 0),
+       .irq_dest_mode                  = 0, /* physical */
 
        .target_cpus                    = physflat_target_cpus,
        .disable_esr                    = 0,
index c1cffae4a4c2c81deb9c1d0343599331fbd6429a..a76e75ecc20680f618cfbdf38fc4a842b2f6dcbf 100644 (file)
@@ -64,7 +64,7 @@ static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector)
        for_each_cpu(query_cpu, mask)
                __x2apic_send_IPI_dest(
                        per_cpu(x86_cpu_to_logical_apicid, query_cpu),
-                       vector, APIC_DEST_LOGICAL);
+                       vector, apic->apic_destination_logical);
        local_irq_restore(flags);
 }
 
@@ -80,7 +80,7 @@ static void x2apic_send_IPI_mask_allbutself(const struct cpumask *mask,
                if (query_cpu != this_cpu)
                        __x2apic_send_IPI_dest(
                                per_cpu(x86_cpu_to_logical_apicid, query_cpu),
-                               vector, APIC_DEST_LOGICAL);
+                               vector, apic->apic_destination_logical);
        local_irq_restore(flags);
 }
 
@@ -95,7 +95,7 @@ static void x2apic_send_IPI_allbutself(int vector)
                if (query_cpu != this_cpu)
                        __x2apic_send_IPI_dest(
                                per_cpu(x86_cpu_to_logical_apicid, query_cpu),
-                               vector, APIC_DEST_LOGICAL);
+                               vector, apic->apic_destination_logical);
        local_irq_restore(flags);
 }
 
@@ -183,11 +183,11 @@ struct genapic apic_x2apic_cluster = {
        .apic_id_registered             = x2apic_apic_id_registered,
 
        .irq_delivery_mode              = dest_LowestPrio,
-       .irq_dest_mode                  = (APIC_DEST_LOGICAL != 0),
+       .irq_dest_mode                  = 1, /* logical */
 
        .target_cpus                    = x2apic_target_cpus,
        .disable_esr                    = 0,
-       .apic_destination_logical       = 0,
+       .apic_destination_logical       = APIC_DEST_LOGICAL,
        .check_apicid_used              = NULL,
        .check_apicid_present           = NULL,
 
index c59602be0353e3990edc0bb7cefa5d52ceb734ce..9b6d68deb1472a24c373b8cb8e0a7749332acbc6 100644 (file)
@@ -179,7 +179,7 @@ struct genapic apic_x2apic_phys = {
        .apic_id_registered             = x2apic_apic_id_registered,
 
        .irq_delivery_mode              = dest_Fixed,
-       .irq_dest_mode                  = (APIC_DEST_PHYSICAL != 0),
+       .irq_dest_mode                  = 0, /* physical */
 
        .target_cpus                    = x2apic_target_cpus,
        .disable_esr                    = 0,
index 525b4e480a73926c0f5a4dd4076392337080e2d7..0a756800c11a57c8003ea64cee6648d1f082cd9a 100644 (file)
@@ -244,11 +244,11 @@ struct genapic apic_x2apic_uv_x = {
        .apic_id_registered             = uv_apic_id_registered,
 
        .irq_delivery_mode              = dest_Fixed,
-       .irq_dest_mode                  = (APIC_DEST_PHYSICAL != 0),
+       .irq_dest_mode                  = 1, /* logical */
 
        .target_cpus                    = uv_target_cpus,
        .disable_esr                    = 0,
-       .apic_destination_logical       = 0,
+       .apic_destination_logical       = APIC_DEST_LOGICAL,
        .check_apicid_used              = NULL,
        .check_apicid_present           = NULL,
 
index 7503285e180de03772df50a8d1760e3bcbffbd35..17526d7a8ab341c5bce93a3d2226192f078e3f7f 100644 (file)
@@ -806,7 +806,7 @@ void send_IPI_self(int vector)
         * Wait for idle.
         */
        apic_wait_icr_idle();
-       cfg = APIC_DM_FIXED | APIC_DEST_SELF | vector | APIC_DEST_LOGICAL;
+       cfg = APIC_DM_FIXED | APIC_DEST_SELF | vector | apic->apic_destination_logical;
        /*
         * Send the IPI. The write to APIC_ICR fires this off.
         */
index 285bbf8831faf3cd826a4dd7cbf295ea0684ec21..400b7bd48f670eab3b979c3a1ff2700e016ad244 100644 (file)
@@ -30,7 +30,7 @@
 
 static inline int __prepare_ICR(unsigned int shortcut, int vector)
 {
-       unsigned int icr = shortcut | APIC_DEST_LOGICAL;
+       unsigned int icr = shortcut | apic->apic_destination_logical;
 
        switch (vector) {
        default:
index f9dbcff4354646c73d850f539e1287c66d355020..f0a173718d9f76fa3e396bd673a0e6b3993720f5 100644 (file)
@@ -583,7 +583,7 @@ wakeup_secondary_cpu_via_nmi(int logical_apicid, unsigned long start_eip)
        /* Target chip */
        /* Boot on the stack */
        /* Kick the second */
-       apic_icr_write(APIC_DM_NMI | APIC_DEST_LOGICAL, logical_apicid);
+       apic_icr_write(APIC_DM_NMI |  apic->apic_destination_logical, logical_apicid);
 
        pr_debug("Waiting for send to finish...\n");
        send_status = safe_apic_wait_icr_idle();
index fe9bf252c06930908db9b63469671d758e4d21fb..13ee7dc9b952625e085bf71883905cc721088739 100644 (file)
@@ -70,7 +70,7 @@ struct genapic apic_bigsmp = {
 
        .target_cpus                    = bigsmp_target_cpus,
        .disable_esr                    = 1,
-       .apic_destination_logical       = APIC_DEST_LOGICAL,
+       .apic_destination_logical       = 0,
        .check_apicid_used              = check_apicid_used,
        .check_apicid_present           = check_apicid_present,
 
index b4f8abfb714f3fe9356b023f9a331e595f43d8de..61b5da213ce623137e4e6ac09a8d6b9bb7f4cbbd 100644 (file)
@@ -113,7 +113,7 @@ struct genapic apic_es7000 = {
 
        .target_cpus                    = es7000_target_cpus,
        .disable_esr                    = 1,
-       .apic_destination_logical       = APIC_DEST_LOGICAL,
+       .apic_destination_logical       = 0,
        .check_apicid_used              = check_apicid_used,
        .check_apicid_present           = check_apicid_present,