aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2009-01-29 22:31:49 -0500
committerIngo Molnar <mingo@elte.hu>2009-01-30 09:21:24 -0500
commit43f39890db2959b10891cf7bbf3f53fffc8ce3bd (patch)
tree15e3705c14bfaf10eeed3c3220f1ff298e288b8d
parent1ff2f20de354a621ef4b56b9cfe6f9139a7e493b (diff)
x86: seperate default_send_IPI_mask_sequence/allbutself from logical
Impact: 32-bit should use logical version there are two version: for default_send_IPI_mask_sequence/allbutself one in ipi.h and one in ipi.c for 32bit it seems .h version overwrote ipi.c for a while. restore it so 32 bit could use its old logical version. also remove dupicated functions in .c Signed-off-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/x86/include/asm/ipi.h71
-rw-r--r--arch/x86/kernel/bigsmp_32.c8
-rw-r--r--arch/x86/kernel/es7000_32.c4
-rw-r--r--arch/x86/kernel/genapic_flat_64.c6
-rw-r--r--arch/x86/kernel/ipi.c139
-rw-r--r--arch/x86/kernel/numaq_32.c8
-rw-r--r--arch/x86/kernel/probe_32.c4
-rw-r--r--arch/x86/kernel/summit_32.c6
8 files changed, 77 insertions, 169 deletions
diff --git a/arch/x86/include/asm/ipi.h b/arch/x86/include/asm/ipi.h
index e2e8e4e0a656..aa79945445b5 100644
--- a/arch/x86/include/asm/ipi.h
+++ b/arch/x86/include/asm/ipi.h
@@ -120,7 +120,7 @@ static inline void
120} 120}
121 121
122static inline void 122static inline void
123default_send_IPI_mask_sequence(const struct cpumask *mask, int vector) 123default_send_IPI_mask_sequence_phys(const struct cpumask *mask, int vector)
124{ 124{
125 unsigned long query_cpu; 125 unsigned long query_cpu;
126 unsigned long flags; 126 unsigned long flags;
@@ -139,7 +139,7 @@ default_send_IPI_mask_sequence(const struct cpumask *mask, int vector)
139} 139}
140 140
141static inline void 141static inline void
142default_send_IPI_mask_allbutself(const struct cpumask *mask, int vector) 142default_send_IPI_mask_allbutself_phys(const struct cpumask *mask, int vector)
143{ 143{
144 unsigned int this_cpu = smp_processor_id(); 144 unsigned int this_cpu = smp_processor_id();
145 unsigned int query_cpu; 145 unsigned int query_cpu;
@@ -157,23 +157,72 @@ default_send_IPI_mask_allbutself(const struct cpumask *mask, int vector)
157 local_irq_restore(flags); 157 local_irq_restore(flags);
158} 158}
159 159
160#include <asm/genapic.h>
161
162static inline void
163default_send_IPI_mask_sequence_logical(const struct cpumask *mask, int vector)
164{
165 unsigned long flags;
166 unsigned int query_cpu;
167
168 /*
169 * Hack. The clustered APIC addressing mode doesn't allow us to send
170 * to an arbitrary mask, so I do a unicasts to each CPU instead. This
171 * should be modified to do 1 message per cluster ID - mbligh
172 */
173
174 local_irq_save(flags);
175 for_each_cpu(query_cpu, mask)
176 __default_send_IPI_dest_field(
177 apic->cpu_to_logical_apicid(query_cpu), vector,
178 apic->dest_logical);
179 local_irq_restore(flags);
180}
181
182static inline void
183default_send_IPI_mask_allbutself_logical(const struct cpumask *mask, int vector)
184{
185 unsigned long flags;
186 unsigned int query_cpu;
187 unsigned int this_cpu = smp_processor_id();
188
189 /* See Hack comment above */
190
191 local_irq_save(flags);
192 for_each_cpu(query_cpu, mask) {
193 if (query_cpu == this_cpu)
194 continue;
195 __default_send_IPI_dest_field(
196 apic->cpu_to_logical_apicid(query_cpu), vector,
197 apic->dest_logical);
198 }
199 local_irq_restore(flags);
200}
160 201
161/* Avoid include hell */ 202/* Avoid include hell */
162#define NMI_VECTOR 0x02 203#define NMI_VECTOR 0x02
163 204
164void default_send_IPI_mask_bitmask(const struct cpumask *mask, int vector);
165void default_send_IPI_mask_allbutself(const struct cpumask *mask, int vector);
166
167extern int no_broadcast; 205extern int no_broadcast;
168 206
169#ifdef CONFIG_X86_64 207#ifndef CONFIG_X86_64
170#include <asm/genapic.h> 208/*
171#else 209 * This is only used on smaller machines.
172static inline void default_send_IPI_mask(const struct cpumask *mask, int vector) 210 */
211static inline void default_send_IPI_mask_bitmask_logical(const struct cpumask *cpumask, int vector)
212{
213 unsigned long mask = cpumask_bits(cpumask)[0];
214 unsigned long flags;
215
216 local_irq_save(flags);
217 WARN_ON(mask & ~cpumask_bits(cpu_online_mask)[0]);
218 __default_send_IPI_dest_field(mask, vector, apic->dest_logical);
219 local_irq_restore(flags);
220}
221
222static inline void default_send_IPI_mask_logical(const struct cpumask *mask, int vector)
173{ 223{
174 default_send_IPI_mask_bitmask(mask, vector); 224 default_send_IPI_mask_bitmask_logical(mask, vector);
175} 225}
176void default_send_IPI_mask_allbutself(const struct cpumask *mask, int vector);
177#endif 226#endif
178 227
179static inline void __default_local_send_IPI_allbutself(int vector) 228static inline void __default_local_send_IPI_allbutself(int vector)
diff --git a/arch/x86/kernel/bigsmp_32.c b/arch/x86/kernel/bigsmp_32.c
index b1f91931003f..ab645c93a6e7 100644
--- a/arch/x86/kernel/bigsmp_32.c
+++ b/arch/x86/kernel/bigsmp_32.c
@@ -9,6 +9,7 @@
9#include <asm/genapic.h> 9#include <asm/genapic.h>
10#include <asm/fixmap.h> 10#include <asm/fixmap.h>
11#include <asm/apicdef.h> 11#include <asm/apicdef.h>
12#include <asm/ipi.h>
12#include <linux/kernel.h> 13#include <linux/kernel.h>
13#include <linux/init.h> 14#include <linux/init.h>
14#include <linux/dmi.h> 15#include <linux/dmi.h>
@@ -154,17 +155,14 @@ static inline int bigsmp_phys_pkg_id(int cpuid_apic, int index_msb)
154 return cpuid_apic >> index_msb; 155 return cpuid_apic >> index_msb;
155} 156}
156 157
157void default_send_IPI_mask_sequence(const struct cpumask *mask, int vector);
158void default_send_IPI_mask_allbutself(const struct cpumask *mask, int vector);
159
160static inline void bigsmp_send_IPI_mask(const struct cpumask *mask, int vector) 158static inline void bigsmp_send_IPI_mask(const struct cpumask *mask, int vector)
161{ 159{
162 default_send_IPI_mask_sequence(mask, vector); 160 default_send_IPI_mask_sequence_phys(mask, vector);
163} 161}
164 162
165static inline void bigsmp_send_IPI_allbutself(int vector) 163static inline void bigsmp_send_IPI_allbutself(int vector)
166{ 164{
167 default_send_IPI_mask_allbutself(cpu_online_mask, vector); 165 default_send_IPI_mask_allbutself_phys(cpu_online_mask, vector);
168} 166}
169 167
170static inline void bigsmp_send_IPI_all(int vector) 168static inline void bigsmp_send_IPI_all(int vector)
diff --git a/arch/x86/kernel/es7000_32.c b/arch/x86/kernel/es7000_32.c
index 078364ccfa07..b5b50e8b94a9 100644
--- a/arch/x86/kernel/es7000_32.c
+++ b/arch/x86/kernel/es7000_32.c
@@ -451,12 +451,12 @@ static int es7000_check_dsdt(void)
451 451
452static void es7000_send_IPI_mask(const struct cpumask *mask, int vector) 452static void es7000_send_IPI_mask(const struct cpumask *mask, int vector)
453{ 453{
454 default_send_IPI_mask_sequence(mask, vector); 454 default_send_IPI_mask_sequence_phys(mask, vector);
455} 455}
456 456
457static void es7000_send_IPI_allbutself(int vector) 457static void es7000_send_IPI_allbutself(int vector)
458{ 458{
459 default_send_IPI_mask_allbutself(cpu_online_mask, vector); 459 default_send_IPI_mask_allbutself_phys(cpu_online_mask, vector);
460} 460}
461 461
462static void es7000_send_IPI_all(int vector) 462static void es7000_send_IPI_all(int vector)
diff --git a/arch/x86/kernel/genapic_flat_64.c b/arch/x86/kernel/genapic_flat_64.c
index 19bffb3f7320..249d2d3c034c 100644
--- a/arch/x86/kernel/genapic_flat_64.c
+++ b/arch/x86/kernel/genapic_flat_64.c
@@ -267,18 +267,18 @@ static void physflat_vector_allocation_domain(int cpu, struct cpumask *retmask)
267 267
268static void physflat_send_IPI_mask(const struct cpumask *cpumask, int vector) 268static void physflat_send_IPI_mask(const struct cpumask *cpumask, int vector)
269{ 269{
270 default_send_IPI_mask_sequence(cpumask, vector); 270 default_send_IPI_mask_sequence_phys(cpumask, vector);
271} 271}
272 272
273static void physflat_send_IPI_mask_allbutself(const struct cpumask *cpumask, 273static void physflat_send_IPI_mask_allbutself(const struct cpumask *cpumask,
274 int vector) 274 int vector)
275{ 275{
276 default_send_IPI_mask_allbutself(cpumask, vector); 276 default_send_IPI_mask_allbutself_phys(cpumask, vector);
277} 277}
278 278
279static void physflat_send_IPI_allbutself(int vector) 279static void physflat_send_IPI_allbutself(int vector)
280{ 280{
281 default_send_IPI_mask_allbutself(cpu_online_mask, vector); 281 default_send_IPI_mask_allbutself_phys(cpu_online_mask, vector);
282} 282}
283 283
284static void physflat_send_IPI_all(int vector) 284static void physflat_send_IPI_all(int vector)
diff --git a/arch/x86/kernel/ipi.c b/arch/x86/kernel/ipi.c
index 0893fa144581..339f4f3feee5 100644
--- a/arch/x86/kernel/ipi.c
+++ b/arch/x86/kernel/ipi.c
@@ -17,148 +17,13 @@
17#include <asm/mmu_context.h> 17#include <asm/mmu_context.h>
18#include <asm/apic.h> 18#include <asm/apic.h>
19#include <asm/proto.h> 19#include <asm/proto.h>
20#include <asm/ipi.h>
20 21
21#ifdef CONFIG_X86_32 22#ifdef CONFIG_X86_32
22#include <asm/genapic.h>
23
24/*
25 * the following functions deal with sending IPIs between CPUs.
26 *
27 * We use 'broadcast', CPU->CPU IPIs and self-IPIs too.
28 */
29
30static inline int __prepare_ICR(unsigned int shortcut, int vector)
31{
32 unsigned int icr = shortcut | apic->dest_logical;
33
34 switch (vector) {
35 default:
36 icr |= APIC_DM_FIXED | vector;
37 break;
38 case NMI_VECTOR:
39 icr |= APIC_DM_NMI;
40 break;
41 }
42 return icr;
43}
44
45static inline int __prepare_ICR2(unsigned int mask)
46{
47 return SET_APIC_DEST_FIELD(mask);
48}
49
50void __default_send_IPI_shortcut(unsigned int shortcut, int vector)
51{
52 /*
53 * Subtle. In the case of the 'never do double writes' workaround
54 * we have to lock out interrupts to be safe. As we don't care
55 * of the value read we use an atomic rmw access to avoid costly
56 * cli/sti. Otherwise we use an even cheaper single atomic write
57 * to the APIC.
58 */
59 unsigned int cfg;
60
61 /*
62 * Wait for idle.
63 */
64 apic_wait_icr_idle();
65
66 /*
67 * No need to touch the target chip field
68 */
69 cfg = __prepare_ICR(shortcut, vector);
70
71 /*
72 * Send the IPI. The write to APIC_ICR fires this off.
73 */
74 apic_write(APIC_ICR, cfg);
75}
76 23
77void default_send_IPI_self(int vector) 24void default_send_IPI_self(int vector)
78{ 25{
79 __default_send_IPI_shortcut(APIC_DEST_SELF, vector); 26 __default_send_IPI_shortcut(APIC_DEST_SELF, vector, apic->dest_logical);
80}
81
82/*
83 * This is used to send an IPI with no shorthand notation (the destination is
84 * specified in bits 56 to 63 of the ICR).
85 */
86static inline void __default_send_IPI_dest_field(unsigned long mask, int vector)
87{
88 unsigned long cfg;
89
90 /*
91 * Wait for idle.
92 */
93 if (unlikely(vector == NMI_VECTOR))
94 safe_apic_wait_icr_idle();
95 else
96 apic_wait_icr_idle();
97
98 /*
99 * prepare target chip field
100 */
101 cfg = __prepare_ICR2(mask);
102 apic_write(APIC_ICR2, cfg);
103
104 /*
105 * program the ICR
106 */
107 cfg = __prepare_ICR(0, vector);
108
109 /*
110 * Send the IPI. The write to APIC_ICR fires this off.
111 */
112 apic_write(APIC_ICR, cfg);
113}
114
115/*
116 * This is only used on smaller machines.
117 */
118void default_send_IPI_mask_bitmask(const struct cpumask *cpumask, int vector)
119{
120 unsigned long mask = cpumask_bits(cpumask)[0];
121 unsigned long flags;
122
123 local_irq_save(flags);
124 WARN_ON(mask & ~cpumask_bits(cpu_online_mask)[0]);
125 __default_send_IPI_dest_field(mask, vector);
126 local_irq_restore(flags);
127}
128
129void default_send_IPI_mask_sequence(const struct cpumask *mask, int vector)
130{
131 unsigned long flags;
132 unsigned int query_cpu;
133
134 /*
135 * Hack. The clustered APIC addressing mode doesn't allow us to send
136 * to an arbitrary mask, so I do a unicasts to each CPU instead. This
137 * should be modified to do 1 message per cluster ID - mbligh
138 */
139
140 local_irq_save(flags);
141 for_each_cpu(query_cpu, mask)
142 __default_send_IPI_dest_field(apic->cpu_to_logical_apicid(query_cpu), vector);
143 local_irq_restore(flags);
144}
145
146void default_send_IPI_mask_allbutself(const struct cpumask *mask, int vector)
147{
148 unsigned long flags;
149 unsigned int query_cpu;
150 unsigned int this_cpu = smp_processor_id();
151
152 /* See Hack comment above */
153
154 local_irq_save(flags);
155 for_each_cpu(query_cpu, mask) {
156 if (query_cpu == this_cpu)
157 continue;
158 __default_send_IPI_dest_field(
159 apic->cpu_to_logical_apicid(query_cpu), vector);
160 }
161 local_irq_restore(flags);
162} 27}
163 28
164/* must come after the send_IPI functions above for inlining */ 29/* must come after the send_IPI functions above for inlining */
diff --git a/arch/x86/kernel/numaq_32.c b/arch/x86/kernel/numaq_32.c
index 83bb05524f43..c143b3292163 100644
--- a/arch/x86/kernel/numaq_32.c
+++ b/arch/x86/kernel/numaq_32.c
@@ -302,6 +302,7 @@ int __init get_memcfg_numaq(void)
302#include <asm/genapic.h> 302#include <asm/genapic.h>
303#include <asm/fixmap.h> 303#include <asm/fixmap.h>
304#include <asm/apicdef.h> 304#include <asm/apicdef.h>
305#include <asm/ipi.h>
305#include <linux/kernel.h> 306#include <linux/kernel.h>
306#include <linux/string.h> 307#include <linux/string.h>
307#include <linux/init.h> 308#include <linux/init.h>
@@ -319,17 +320,14 @@ static inline unsigned int numaq_get_apic_id(unsigned long x)
319 return (x >> 24) & 0x0F; 320 return (x >> 24) & 0x0F;
320} 321}
321 322
322void default_send_IPI_mask_sequence(const struct cpumask *mask, int vector);
323void default_send_IPI_mask_allbutself(const struct cpumask *mask, int vector);
324
325static inline void numaq_send_IPI_mask(const struct cpumask *mask, int vector) 323static inline void numaq_send_IPI_mask(const struct cpumask *mask, int vector)
326{ 324{
327 default_send_IPI_mask_sequence(mask, vector); 325 default_send_IPI_mask_sequence_logical(mask, vector);
328} 326}
329 327
330static inline void numaq_send_IPI_allbutself(int vector) 328static inline void numaq_send_IPI_allbutself(int vector)
331{ 329{
332 default_send_IPI_mask_allbutself(cpu_online_mask, vector); 330 default_send_IPI_mask_allbutself_logical(cpu_online_mask, vector);
333} 331}
334 332
335static inline void numaq_send_IPI_all(int vector) 333static inline void numaq_send_IPI_all(int vector)
diff --git a/arch/x86/kernel/probe_32.c b/arch/x86/kernel/probe_32.c
index b5db26f8e069..3f12a4011822 100644
--- a/arch/x86/kernel/probe_32.c
+++ b/arch/x86/kernel/probe_32.c
@@ -112,8 +112,8 @@ struct genapic apic_default = {
112 .cpu_mask_to_apicid = default_cpu_mask_to_apicid, 112 .cpu_mask_to_apicid = default_cpu_mask_to_apicid,
113 .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, 113 .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,
114 114
115 .send_IPI_mask = default_send_IPI_mask, 115 .send_IPI_mask = default_send_IPI_mask_logical,
116 .send_IPI_mask_allbutself = default_send_IPI_mask_allbutself, 116 .send_IPI_mask_allbutself = default_send_IPI_mask_allbutself_logical,
117 .send_IPI_allbutself = default_send_IPI_allbutself, 117 .send_IPI_allbutself = default_send_IPI_allbutself,
118 .send_IPI_all = default_send_IPI_all, 118 .send_IPI_all = default_send_IPI_all,
119 .send_IPI_self = NULL, 119 .send_IPI_self = NULL,
diff --git a/arch/x86/kernel/summit_32.c b/arch/x86/kernel/summit_32.c
index 84ff9ebbcc97..ecb41b9d7aa0 100644
--- a/arch/x86/kernel/summit_32.c
+++ b/arch/x86/kernel/summit_32.c
@@ -43,6 +43,7 @@
43#include <asm/genapic.h> 43#include <asm/genapic.h>
44#include <asm/fixmap.h> 44#include <asm/fixmap.h>
45#include <asm/apicdef.h> 45#include <asm/apicdef.h>
46#include <asm/ipi.h>
46#include <linux/kernel.h> 47#include <linux/kernel.h>
47#include <linux/string.h> 48#include <linux/string.h>
48#include <linux/init.h> 49#include <linux/init.h>
@@ -54,12 +55,9 @@ static inline unsigned summit_get_apic_id(unsigned long x)
54 return (x >> 24) & 0xFF; 55 return (x >> 24) & 0xFF;
55} 56}
56 57
57void default_send_IPI_mask_sequence(const cpumask_t *mask, int vector);
58void default_send_IPI_mask_allbutself(const cpumask_t *mask, int vector);
59
60static inline void summit_send_IPI_mask(const cpumask_t *mask, int vector) 58static inline void summit_send_IPI_mask(const cpumask_t *mask, int vector)
61{ 59{
62 default_send_IPI_mask_sequence(mask, vector); 60 default_send_IPI_mask_sequence_logical(mask, vector);
63} 61}
64 62
65static inline void summit_send_IPI_allbutself(int vector) 63static inline void summit_send_IPI_allbutself(int vector)