diff options
author | Alexander Gordeev <agordeev@redhat.com> | 2012-06-05 07:23:44 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2012-06-06 04:22:18 -0400 |
commit | 6398268d2bc454735f11e08705e858f9fdf5c750 (patch) | |
tree | f6b430e540f1a5da11b371d450d3262550a330b0 /arch | |
parent | bf721d3a3bc7a731add45c8078b142b494ab413e (diff) |
x86/apic: Factor out default cpu_mask_to_apicid() operations
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Link: http://lkml.kernel.org/r/20120605112340.GA11454@dhcp-26-207.brq.redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/include/asm/apic.h | 13 | ||||
-rw-r--r-- | arch/x86/kernel/apic/apic.c | 28 | ||||
-rw-r--r-- | arch/x86/kernel/apic/apic_flat_64.c | 40 | ||||
-rw-r--r-- | arch/x86/kernel/apic/apic_noop.c | 4 | ||||
-rw-r--r-- | arch/x86/kernel/apic/apic_numachip.c | 36 | ||||
-rw-r--r-- | arch/x86/kernel/apic/bigsmp_32.c | 30 | ||||
-rw-r--r-- | arch/x86/kernel/apic/probe_32.c | 4 | ||||
-rw-r--r-- | arch/x86/kernel/apic/x2apic_phys.c | 36 |
8 files changed, 52 insertions, 139 deletions
diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h index fc38195d6405..bef571769e68 100644 --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h | |||
@@ -592,14 +592,14 @@ static inline int default_phys_pkg_id(int cpuid_apic, int index_msb) | |||
592 | #endif | 592 | #endif |
593 | 593 | ||
594 | static inline unsigned int | 594 | static inline unsigned int |
595 | default_cpu_mask_to_apicid(const struct cpumask *cpumask) | 595 | flat_cpu_mask_to_apicid(const struct cpumask *cpumask) |
596 | { | 596 | { |
597 | return cpumask_bits(cpumask)[0] & APIC_ALL_CPUS; | 597 | return cpumask_bits(cpumask)[0] & APIC_ALL_CPUS; |
598 | } | 598 | } |
599 | 599 | ||
600 | static inline unsigned int | 600 | static inline unsigned int |
601 | default_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | 601 | flat_cpu_mask_to_apicid_and(const struct cpumask *cpumask, |
602 | const struct cpumask *andmask) | 602 | const struct cpumask *andmask) |
603 | { | 603 | { |
604 | unsigned long mask1 = cpumask_bits(cpumask)[0]; | 604 | unsigned long mask1 = cpumask_bits(cpumask)[0]; |
605 | unsigned long mask2 = cpumask_bits(andmask)[0]; | 605 | unsigned long mask2 = cpumask_bits(andmask)[0]; |
@@ -608,6 +608,13 @@ default_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | |||
608 | return (unsigned int)(mask1 & mask2 & mask3); | 608 | return (unsigned int)(mask1 & mask2 & mask3); |
609 | } | 609 | } |
610 | 610 | ||
611 | extern unsigned int | ||
612 | default_cpu_mask_to_apicid(const struct cpumask *cpumask); | ||
613 | |||
614 | extern unsigned int | ||
615 | default_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | ||
616 | const struct cpumask *andmask); | ||
617 | |||
611 | static inline unsigned long default_check_apicid_used(physid_mask_t *map, int apicid) | 618 | static inline unsigned long default_check_apicid_used(physid_mask_t *map, int apicid) |
612 | { | 619 | { |
613 | return physid_isset(apicid, *map); | 620 | return physid_isset(apicid, *map); |
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index 39a222e094af..96a2608252f1 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c | |||
@@ -2123,6 +2123,34 @@ void default_init_apic_ldr(void) | |||
2123 | apic_write(APIC_LDR, val); | 2123 | apic_write(APIC_LDR, val); |
2124 | } | 2124 | } |
2125 | 2125 | ||
2126 | unsigned int default_cpu_mask_to_apicid(const struct cpumask *cpumask) | ||
2127 | { | ||
2128 | int cpu; | ||
2129 | |||
2130 | /* | ||
2131 | * We're using fixed IRQ delivery, can only return one phys APIC ID. | ||
2132 | * May as well be the first. | ||
2133 | */ | ||
2134 | cpu = cpumask_first(cpumask); | ||
2135 | if (likely((unsigned)cpu < nr_cpu_ids)) | ||
2136 | return per_cpu(x86_cpu_to_apicid, cpu); | ||
2137 | |||
2138 | return BAD_APICID; | ||
2139 | } | ||
2140 | |||
2141 | unsigned int | ||
2142 | default_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | ||
2143 | const struct cpumask *andmask) | ||
2144 | { | ||
2145 | int cpu; | ||
2146 | |||
2147 | for_each_cpu_and(cpu, cpumask, andmask) { | ||
2148 | if (cpumask_test_cpu(cpu, cpu_online_mask)) | ||
2149 | break; | ||
2150 | } | ||
2151 | return per_cpu(x86_cpu_to_apicid, cpu); | ||
2152 | } | ||
2153 | |||
2126 | /* | 2154 | /* |
2127 | * Power management | 2155 | * Power management |
2128 | */ | 2156 | */ |
diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c index 61ac1afeff07..55b97ce4fa19 100644 --- a/arch/x86/kernel/apic/apic_flat_64.c +++ b/arch/x86/kernel/apic/apic_flat_64.c | |||
@@ -205,8 +205,8 @@ static struct apic apic_flat = { | |||
205 | .set_apic_id = set_apic_id, | 205 | .set_apic_id = set_apic_id, |
206 | .apic_id_mask = 0xFFu << 24, | 206 | .apic_id_mask = 0xFFu << 24, |
207 | 207 | ||
208 | .cpu_mask_to_apicid = default_cpu_mask_to_apicid, | 208 | .cpu_mask_to_apicid = flat_cpu_mask_to_apicid, |
209 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, | 209 | .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and, |
210 | 210 | ||
211 | .send_IPI_mask = flat_send_IPI_mask, | 211 | .send_IPI_mask = flat_send_IPI_mask, |
212 | .send_IPI_mask_allbutself = flat_send_IPI_mask_allbutself, | 212 | .send_IPI_mask_allbutself = flat_send_IPI_mask_allbutself, |
@@ -284,38 +284,6 @@ static void physflat_send_IPI_all(int vector) | |||
284 | physflat_send_IPI_mask(cpu_online_mask, vector); | 284 | physflat_send_IPI_mask(cpu_online_mask, vector); |
285 | } | 285 | } |
286 | 286 | ||
287 | static unsigned int physflat_cpu_mask_to_apicid(const struct cpumask *cpumask) | ||
288 | { | ||
289 | int cpu; | ||
290 | |||
291 | /* | ||
292 | * We're using fixed IRQ delivery, can only return one phys APIC ID. | ||
293 | * May as well be the first. | ||
294 | */ | ||
295 | cpu = cpumask_first(cpumask); | ||
296 | if ((unsigned)cpu < nr_cpu_ids) | ||
297 | return per_cpu(x86_cpu_to_apicid, cpu); | ||
298 | else | ||
299 | return BAD_APICID; | ||
300 | } | ||
301 | |||
302 | static unsigned int | ||
303 | physflat_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | ||
304 | const struct cpumask *andmask) | ||
305 | { | ||
306 | int cpu; | ||
307 | |||
308 | /* | ||
309 | * We're using fixed IRQ delivery, can only return one phys APIC ID. | ||
310 | * May as well be the first. | ||
311 | */ | ||
312 | for_each_cpu_and(cpu, cpumask, andmask) { | ||
313 | if (cpumask_test_cpu(cpu, cpu_online_mask)) | ||
314 | break; | ||
315 | } | ||
316 | return per_cpu(x86_cpu_to_apicid, cpu); | ||
317 | } | ||
318 | |||
319 | static int physflat_probe(void) | 287 | static int physflat_probe(void) |
320 | { | 288 | { |
321 | if (apic == &apic_physflat || num_possible_cpus() > 8) | 289 | if (apic == &apic_physflat || num_possible_cpus() > 8) |
@@ -360,8 +328,8 @@ static struct apic apic_physflat = { | |||
360 | .set_apic_id = set_apic_id, | 328 | .set_apic_id = set_apic_id, |
361 | .apic_id_mask = 0xFFu << 24, | 329 | .apic_id_mask = 0xFFu << 24, |
362 | 330 | ||
363 | .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid, | 331 | .cpu_mask_to_apicid = default_cpu_mask_to_apicid, |
364 | .cpu_mask_to_apicid_and = physflat_cpu_mask_to_apicid_and, | 332 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, |
365 | 333 | ||
366 | .send_IPI_mask = physflat_send_IPI_mask, | 334 | .send_IPI_mask = physflat_send_IPI_mask, |
367 | .send_IPI_mask_allbutself = physflat_send_IPI_mask_allbutself, | 335 | .send_IPI_mask_allbutself = physflat_send_IPI_mask_allbutself, |
diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c index a6e4c6e06c08..7c3dd4fe0686 100644 --- a/arch/x86/kernel/apic/apic_noop.c +++ b/arch/x86/kernel/apic/apic_noop.c | |||
@@ -159,8 +159,8 @@ struct apic apic_noop = { | |||
159 | .set_apic_id = NULL, | 159 | .set_apic_id = NULL, |
160 | .apic_id_mask = 0x0F << 24, | 160 | .apic_id_mask = 0x0F << 24, |
161 | 161 | ||
162 | .cpu_mask_to_apicid = default_cpu_mask_to_apicid, | 162 | .cpu_mask_to_apicid = flat_cpu_mask_to_apicid, |
163 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, | 163 | .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and, |
164 | 164 | ||
165 | .send_IPI_mask = noop_send_IPI_mask, | 165 | .send_IPI_mask = noop_send_IPI_mask, |
166 | .send_IPI_mask_allbutself = noop_send_IPI_mask_allbutself, | 166 | .send_IPI_mask_allbutself = noop_send_IPI_mask_allbutself, |
diff --git a/arch/x86/kernel/apic/apic_numachip.c b/arch/x86/kernel/apic/apic_numachip.c index 3255a60fcc95..dba4bf2ed566 100644 --- a/arch/x86/kernel/apic/apic_numachip.c +++ b/arch/x86/kernel/apic/apic_numachip.c | |||
@@ -152,38 +152,6 @@ static void numachip_send_IPI_self(int vector) | |||
152 | __default_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL); | 152 | __default_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL); |
153 | } | 153 | } |
154 | 154 | ||
155 | static unsigned int numachip_cpu_mask_to_apicid(const struct cpumask *cpumask) | ||
156 | { | ||
157 | int cpu; | ||
158 | |||
159 | /* | ||
160 | * We're using fixed IRQ delivery, can only return one phys APIC ID. | ||
161 | * May as well be the first. | ||
162 | */ | ||
163 | cpu = cpumask_first(cpumask); | ||
164 | if (likely((unsigned)cpu < nr_cpu_ids)) | ||
165 | return per_cpu(x86_cpu_to_apicid, cpu); | ||
166 | |||
167 | return BAD_APICID; | ||
168 | } | ||
169 | |||
170 | static unsigned int | ||
171 | numachip_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | ||
172 | const struct cpumask *andmask) | ||
173 | { | ||
174 | int cpu; | ||
175 | |||
176 | /* | ||
177 | * We're using fixed IRQ delivery, can only return one phys APIC ID. | ||
178 | * May as well be the first. | ||
179 | */ | ||
180 | for_each_cpu_and(cpu, cpumask, andmask) { | ||
181 | if (cpumask_test_cpu(cpu, cpu_online_mask)) | ||
182 | break; | ||
183 | } | ||
184 | return per_cpu(x86_cpu_to_apicid, cpu); | ||
185 | } | ||
186 | |||
187 | static int __init numachip_probe(void) | 155 | static int __init numachip_probe(void) |
188 | { | 156 | { |
189 | return apic == &apic_numachip; | 157 | return apic == &apic_numachip; |
@@ -272,8 +240,8 @@ static struct apic apic_numachip __refconst = { | |||
272 | .set_apic_id = set_apic_id, | 240 | .set_apic_id = set_apic_id, |
273 | .apic_id_mask = 0xffU << 24, | 241 | .apic_id_mask = 0xffU << 24, |
274 | 242 | ||
275 | .cpu_mask_to_apicid = numachip_cpu_mask_to_apicid, | 243 | .cpu_mask_to_apicid = default_cpu_mask_to_apicid, |
276 | .cpu_mask_to_apicid_and = numachip_cpu_mask_to_apicid_and, | 244 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, |
277 | 245 | ||
278 | .send_IPI_mask = numachip_send_IPI_mask, | 246 | .send_IPI_mask = numachip_send_IPI_mask, |
279 | .send_IPI_mask_allbutself = numachip_send_IPI_mask_allbutself, | 247 | .send_IPI_mask_allbutself = numachip_send_IPI_mask_allbutself, |
diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c index c288e81e00ff..907aa3d112a6 100644 --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c | |||
@@ -96,32 +96,6 @@ static int bigsmp_check_phys_apicid_present(int phys_apicid) | |||
96 | return 1; | 96 | return 1; |
97 | } | 97 | } |
98 | 98 | ||
99 | /* As we are using single CPU as destination, pick only one CPU here */ | ||
100 | static unsigned int bigsmp_cpu_mask_to_apicid(const struct cpumask *cpumask) | ||
101 | { | ||
102 | int cpu = cpumask_first(cpumask); | ||
103 | |||
104 | if (cpu < nr_cpu_ids) | ||
105 | return cpu_physical_id(cpu); | ||
106 | return BAD_APICID; | ||
107 | } | ||
108 | |||
109 | static unsigned int bigsmp_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | ||
110 | const struct cpumask *andmask) | ||
111 | { | ||
112 | int cpu; | ||
113 | |||
114 | /* | ||
115 | * We're using fixed IRQ delivery, can only return one phys APIC ID. | ||
116 | * May as well be the first. | ||
117 | */ | ||
118 | for_each_cpu_and(cpu, cpumask, andmask) { | ||
119 | if (cpumask_test_cpu(cpu, cpu_online_mask)) | ||
120 | return cpu_physical_id(cpu); | ||
121 | } | ||
122 | return BAD_APICID; | ||
123 | } | ||
124 | |||
125 | static int bigsmp_phys_pkg_id(int cpuid_apic, int index_msb) | 99 | static int bigsmp_phys_pkg_id(int cpuid_apic, int index_msb) |
126 | { | 100 | { |
127 | return cpuid_apic >> index_msb; | 101 | return cpuid_apic >> index_msb; |
@@ -220,8 +194,8 @@ static struct apic apic_bigsmp = { | |||
220 | .set_apic_id = NULL, | 194 | .set_apic_id = NULL, |
221 | .apic_id_mask = 0xFF << 24, | 195 | .apic_id_mask = 0xFF << 24, |
222 | 196 | ||
223 | .cpu_mask_to_apicid = bigsmp_cpu_mask_to_apicid, | 197 | .cpu_mask_to_apicid = default_cpu_mask_to_apicid, |
224 | .cpu_mask_to_apicid_and = bigsmp_cpu_mask_to_apicid_and, | 198 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, |
225 | 199 | ||
226 | .send_IPI_mask = bigsmp_send_IPI_mask, | 200 | .send_IPI_mask = bigsmp_send_IPI_mask, |
227 | .send_IPI_mask_allbutself = NULL, | 201 | .send_IPI_mask_allbutself = NULL, |
diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c index 1b291da09e60..71b6ac48ab26 100644 --- a/arch/x86/kernel/apic/probe_32.c +++ b/arch/x86/kernel/apic/probe_32.c | |||
@@ -123,8 +123,8 @@ static struct apic apic_default = { | |||
123 | .set_apic_id = NULL, | 123 | .set_apic_id = NULL, |
124 | .apic_id_mask = 0x0F << 24, | 124 | .apic_id_mask = 0x0F << 24, |
125 | 125 | ||
126 | .cpu_mask_to_apicid = default_cpu_mask_to_apicid, | 126 | .cpu_mask_to_apicid = flat_cpu_mask_to_apicid, |
127 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, | 127 | .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and, |
128 | 128 | ||
129 | .send_IPI_mask = default_send_IPI_mask_logical, | 129 | .send_IPI_mask = default_send_IPI_mask_logical, |
130 | .send_IPI_mask_allbutself = default_send_IPI_mask_allbutself_logical, | 130 | .send_IPI_mask_allbutself = default_send_IPI_mask_allbutself_logical, |
diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c index b1a8b39e3c3f..f730269edef2 100644 --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c | |||
@@ -76,38 +76,6 @@ static void x2apic_send_IPI_all(int vector) | |||
76 | __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLINC); | 76 | __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLINC); |
77 | } | 77 | } |
78 | 78 | ||
79 | static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask) | ||
80 | { | ||
81 | /* | ||
82 | * We're using fixed IRQ delivery, can only return one phys APIC ID. | ||
83 | * May as well be the first. | ||
84 | */ | ||
85 | int cpu = cpumask_first(cpumask); | ||
86 | |||
87 | if ((unsigned)cpu < nr_cpu_ids) | ||
88 | return per_cpu(x86_cpu_to_apicid, cpu); | ||
89 | else | ||
90 | return BAD_APICID; | ||
91 | } | ||
92 | |||
93 | static unsigned int | ||
94 | x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | ||
95 | const struct cpumask *andmask) | ||
96 | { | ||
97 | int cpu; | ||
98 | |||
99 | /* | ||
100 | * We're using fixed IRQ delivery, can only return one phys APIC ID. | ||
101 | * May as well be the first. | ||
102 | */ | ||
103 | for_each_cpu_and(cpu, cpumask, andmask) { | ||
104 | if (cpumask_test_cpu(cpu, cpu_online_mask)) | ||
105 | break; | ||
106 | } | ||
107 | |||
108 | return per_cpu(x86_cpu_to_apicid, cpu); | ||
109 | } | ||
110 | |||
111 | static void init_x2apic_ldr(void) | 79 | static void init_x2apic_ldr(void) |
112 | { | 80 | { |
113 | } | 81 | } |
@@ -164,8 +132,8 @@ static struct apic apic_x2apic_phys = { | |||
164 | .set_apic_id = x2apic_set_apic_id, | 132 | .set_apic_id = x2apic_set_apic_id, |
165 | .apic_id_mask = 0xFFFFFFFFu, | 133 | .apic_id_mask = 0xFFFFFFFFu, |
166 | 134 | ||
167 | .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid, | 135 | .cpu_mask_to_apicid = default_cpu_mask_to_apicid, |
168 | .cpu_mask_to_apicid_and = x2apic_cpu_mask_to_apicid_and, | 136 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, |
169 | 137 | ||
170 | .send_IPI_mask = x2apic_send_IPI_mask, | 138 | .send_IPI_mask = x2apic_send_IPI_mask, |
171 | .send_IPI_mask_allbutself = x2apic_send_IPI_mask_allbutself, | 139 | .send_IPI_mask_allbutself = x2apic_send_IPI_mask_allbutself, |