diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-01-28 09:20:18 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-01-28 17:20:30 -0500 |
commit | debccb3e77be52cfc26c5a99e123c114c5c72aeb (patch) | |
tree | 27c015b45085b2042737d94a3fbd3c62fe143c37 /arch/x86 | |
parent | 94af18755266edf46803564414d74f9621aaded8 (diff) |
x86, apic: refactor ->cpu_mask_to_apicid*()
- spread out the namespace on a per driver basis
- clean up the functions
- get rid of macros
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/include/asm/bigsmp/apic.h | 17 | ||||
-rw-r--r-- | arch/x86/include/asm/es7000/apic.h | 29 | ||||
-rw-r--r-- | arch/x86/include/asm/mach-default/mach_apic.h | 10 | ||||
-rw-r--r-- | arch/x86/include/asm/mach-generic/mach_apic.h | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/numaq/apic.h | 11 | ||||
-rw-r--r-- | arch/x86/include/asm/summit/apic.h | 21 | ||||
-rw-r--r-- | arch/x86/kernel/genapic_flat_64.c | 4 | ||||
-rw-r--r-- | arch/x86/kernel/genx2apic_cluster.c | 15 | ||||
-rw-r--r-- | arch/x86/kernel/genx2apic_phys.c | 15 | ||||
-rw-r--r-- | arch/x86/kernel/genx2apic_uv_x.c | 14 | ||||
-rw-r--r-- | arch/x86/kernel/io_apic.c | 21 | ||||
-rw-r--r-- | arch/x86/mach-generic/bigsmp.c | 4 | ||||
-rw-r--r-- | arch/x86/mach-generic/default.c | 4 | ||||
-rw-r--r-- | arch/x86/mach-generic/es7000.c | 6 | ||||
-rw-r--r-- | arch/x86/mach-generic/numaq.c | 4 | ||||
-rw-r--r-- | arch/x86/mach-generic/summit.c | 4 |
16 files changed, 101 insertions, 80 deletions
diff --git a/arch/x86/include/asm/bigsmp/apic.h b/arch/x86/include/asm/bigsmp/apic.h index 1230f5d7a38e..ee29d66cd302 100644 --- a/arch/x86/include/asm/bigsmp/apic.h +++ b/arch/x86/include/asm/bigsmp/apic.h | |||
@@ -105,18 +105,14 @@ static inline int bigsmp_check_phys_apicid_present(int boot_cpu_physical_apicid) | |||
105 | } | 105 | } |
106 | 106 | ||
107 | /* As we are using single CPU as destination, pick only one CPU here */ | 107 | /* As we are using single CPU as destination, pick only one CPU here */ |
108 | static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask) | 108 | static inline unsigned int bigsmp_cpu_mask_to_apicid(const cpumask_t *cpumask) |
109 | { | 109 | { |
110 | int cpu; | 110 | return bigsmp_cpu_to_logical_apicid(first_cpu(*cpumask)); |
111 | int apicid; | ||
112 | |||
113 | cpu = first_cpu(*cpumask); | ||
114 | apicid = bigsmp_cpu_to_logical_apicid(cpu); | ||
115 | return apicid; | ||
116 | } | 111 | } |
117 | 112 | ||
118 | static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *cpumask, | 113 | static inline unsigned int |
119 | const struct cpumask *andmask) | 114 | bigsmp_cpu_mask_to_apicid_and(const struct cpumask *cpumask, |
115 | const struct cpumask *andmask) | ||
120 | { | 116 | { |
121 | int cpu; | 117 | int cpu; |
122 | 118 | ||
@@ -124,9 +120,10 @@ static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *cpumask, | |||
124 | * We're using fixed IRQ delivery, can only return one phys APIC ID. | 120 | * We're using fixed IRQ delivery, can only return one phys APIC ID. |
125 | * May as well be the first. | 121 | * May as well be the first. |
126 | */ | 122 | */ |
127 | for_each_cpu_and(cpu, cpumask, andmask) | 123 | for_each_cpu_and(cpu, cpumask, andmask) { |
128 | if (cpumask_test_cpu(cpu, cpu_online_mask)) | 124 | if (cpumask_test_cpu(cpu, cpu_online_mask)) |
129 | break; | 125 | break; |
126 | } | ||
130 | if (cpu < nr_cpu_ids) | 127 | if (cpu < nr_cpu_ids) |
131 | return bigsmp_cpu_to_logical_apicid(cpu); | 128 | return bigsmp_cpu_to_logical_apicid(cpu); |
132 | 129 | ||
diff --git a/arch/x86/include/asm/es7000/apic.h b/arch/x86/include/asm/es7000/apic.h index f183dfb4de4a..b89b45db735d 100644 --- a/arch/x86/include/asm/es7000/apic.h +++ b/arch/x86/include/asm/es7000/apic.h | |||
@@ -137,12 +137,12 @@ static inline int es7000_check_phys_apicid_present(int cpu_physical_apicid) | |||
137 | } | 137 | } |
138 | 138 | ||
139 | static inline unsigned int | 139 | static inline unsigned int |
140 | cpu_mask_to_apicid_cluster(const struct cpumask *cpumask) | 140 | es7000_cpu_mask_to_apicid_cluster(const struct cpumask *cpumask) |
141 | { | 141 | { |
142 | int num_bits_set; | ||
143 | int cpus_found = 0; | 142 | int cpus_found = 0; |
144 | int cpu; | 143 | int num_bits_set; |
145 | int apicid; | 144 | int apicid; |
145 | int cpu; | ||
146 | 146 | ||
147 | num_bits_set = cpumask_weight(cpumask); | 147 | num_bits_set = cpumask_weight(cpumask); |
148 | /* Return id to all */ | 148 | /* Return id to all */ |
@@ -154,12 +154,15 @@ cpu_mask_to_apicid_cluster(const struct cpumask *cpumask) | |||
154 | */ | 154 | */ |
155 | cpu = cpumask_first(cpumask); | 155 | cpu = cpumask_first(cpumask); |
156 | apicid = es7000_cpu_to_logical_apicid(cpu); | 156 | apicid = es7000_cpu_to_logical_apicid(cpu); |
157 | |||
157 | while (cpus_found < num_bits_set) { | 158 | while (cpus_found < num_bits_set) { |
158 | if (cpumask_test_cpu(cpu, cpumask)) { | 159 | if (cpumask_test_cpu(cpu, cpumask)) { |
159 | int new_apicid = es7000_cpu_to_logical_apicid(cpu); | 160 | int new_apicid = es7000_cpu_to_logical_apicid(cpu); |
161 | |||
160 | if (apicid_cluster(apicid) != | 162 | if (apicid_cluster(apicid) != |
161 | apicid_cluster(new_apicid)){ | 163 | apicid_cluster(new_apicid)) { |
162 | printk ("%s: Not a valid mask!\n", __func__); | 164 | printk ("%s: Not a valid mask!\n", __func__); |
165 | |||
163 | return 0xFF; | 166 | return 0xFF; |
164 | } | 167 | } |
165 | apicid = new_apicid; | 168 | apicid = new_apicid; |
@@ -170,12 +173,12 @@ cpu_mask_to_apicid_cluster(const struct cpumask *cpumask) | |||
170 | return apicid; | 173 | return apicid; |
171 | } | 174 | } |
172 | 175 | ||
173 | static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask) | 176 | static inline unsigned int es7000_cpu_mask_to_apicid(const cpumask_t *cpumask) |
174 | { | 177 | { |
175 | int num_bits_set; | ||
176 | int cpus_found = 0; | 178 | int cpus_found = 0; |
177 | int cpu; | 179 | int num_bits_set; |
178 | int apicid; | 180 | int apicid; |
181 | int cpu; | ||
179 | 182 | ||
180 | num_bits_set = cpus_weight(*cpumask); | 183 | num_bits_set = cpus_weight(*cpumask); |
181 | /* Return id to all */ | 184 | /* Return id to all */ |
@@ -190,9 +193,11 @@ static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask) | |||
190 | while (cpus_found < num_bits_set) { | 193 | while (cpus_found < num_bits_set) { |
191 | if (cpu_isset(cpu, *cpumask)) { | 194 | if (cpu_isset(cpu, *cpumask)) { |
192 | int new_apicid = es7000_cpu_to_logical_apicid(cpu); | 195 | int new_apicid = es7000_cpu_to_logical_apicid(cpu); |
196 | |||
193 | if (apicid_cluster(apicid) != | 197 | if (apicid_cluster(apicid) != |
194 | apicid_cluster(new_apicid)){ | 198 | apicid_cluster(new_apicid)) { |
195 | printk ("%s: Not a valid mask!\n", __func__); | 199 | printk ("%s: Not a valid mask!\n", __func__); |
200 | |||
196 | return es7000_cpu_to_logical_apicid(0); | 201 | return es7000_cpu_to_logical_apicid(0); |
197 | } | 202 | } |
198 | apicid = new_apicid; | 203 | apicid = new_apicid; |
@@ -204,8 +209,9 @@ static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask) | |||
204 | } | 209 | } |
205 | 210 | ||
206 | 211 | ||
207 | static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *inmask, | 212 | static inline unsigned int |
208 | const struct cpumask *andmask) | 213 | es7000_cpu_mask_to_apicid_and(const struct cpumask *inmask, |
214 | const struct cpumask *andmask) | ||
209 | { | 215 | { |
210 | int apicid = es7000_cpu_to_logical_apicid(0); | 216 | int apicid = es7000_cpu_to_logical_apicid(0); |
211 | cpumask_var_t cpumask; | 217 | cpumask_var_t cpumask; |
@@ -215,9 +221,10 @@ static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *inmask, | |||
215 | 221 | ||
216 | cpumask_and(cpumask, inmask, andmask); | 222 | cpumask_and(cpumask, inmask, andmask); |
217 | cpumask_and(cpumask, cpumask, cpu_online_mask); | 223 | cpumask_and(cpumask, cpumask, cpu_online_mask); |
218 | apicid = cpu_mask_to_apicid(cpumask); | 224 | apicid = es7000_cpu_mask_to_apicid(cpumask); |
219 | 225 | ||
220 | free_cpumask_var(cpumask); | 226 | free_cpumask_var(cpumask); |
227 | |||
221 | return apicid; | 228 | return apicid; |
222 | } | 229 | } |
223 | 230 | ||
diff --git a/arch/x86/include/asm/mach-default/mach_apic.h b/arch/x86/include/asm/mach-default/mach_apic.h index 8719208f2735..8972f8434145 100644 --- a/arch/x86/include/asm/mach-default/mach_apic.h +++ b/arch/x86/include/asm/mach-default/mach_apic.h | |||
@@ -19,8 +19,6 @@ static inline const struct cpumask *default_target_cpus(void) | |||
19 | 19 | ||
20 | #ifdef CONFIG_X86_64 | 20 | #ifdef CONFIG_X86_64 |
21 | #include <asm/genapic.h> | 21 | #include <asm/genapic.h> |
22 | #define cpu_mask_to_apicid (apic->cpu_mask_to_apicid) | ||
23 | #define cpu_mask_to_apicid_and (apic->cpu_mask_to_apicid_and) | ||
24 | #define read_apic_id() (apic->get_apic_id(apic_read(APIC_ID))) | 22 | #define read_apic_id() (apic->get_apic_id(apic_read(APIC_ID))) |
25 | #define send_IPI_self (apic->send_IPI_self) | 23 | #define send_IPI_self (apic->send_IPI_self) |
26 | #define wakeup_secondary_cpu (apic->wakeup_cpu) | 24 | #define wakeup_secondary_cpu (apic->wakeup_cpu) |
@@ -49,13 +47,15 @@ static inline int default_apic_id_registered(void) | |||
49 | return physid_isset(read_apic_id(), phys_cpu_present_map); | 47 | return physid_isset(read_apic_id(), phys_cpu_present_map); |
50 | } | 48 | } |
51 | 49 | ||
52 | static inline unsigned int cpu_mask_to_apicid(const struct cpumask *cpumask) | 50 | static inline unsigned int |
51 | default_cpu_mask_to_apicid(const struct cpumask *cpumask) | ||
53 | { | 52 | { |
54 | return cpumask_bits(cpumask)[0]; | 53 | return cpumask_bits(cpumask)[0]; |
55 | } | 54 | } |
56 | 55 | ||
57 | static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *cpumask, | 56 | static inline unsigned int |
58 | const struct cpumask *andmask) | 57 | default_cpu_mask_to_apicid_and(const struct cpumask *cpumask, |
58 | const struct cpumask *andmask) | ||
59 | { | 59 | { |
60 | unsigned long mask1 = cpumask_bits(cpumask)[0]; | 60 | unsigned long mask1 = cpumask_bits(cpumask)[0]; |
61 | unsigned long mask2 = cpumask_bits(andmask)[0]; | 61 | unsigned long mask2 = cpumask_bits(andmask)[0]; |
diff --git a/arch/x86/include/asm/mach-generic/mach_apic.h b/arch/x86/include/asm/mach-generic/mach_apic.h index 1eeb5b61e488..ca460e459913 100644 --- a/arch/x86/include/asm/mach-generic/mach_apic.h +++ b/arch/x86/include/asm/mach-generic/mach_apic.h | |||
@@ -3,8 +3,6 @@ | |||
3 | 3 | ||
4 | #include <asm/genapic.h> | 4 | #include <asm/genapic.h> |
5 | 5 | ||
6 | #define cpu_mask_to_apicid (apic->cpu_mask_to_apicid) | ||
7 | #define cpu_mask_to_apicid_and (apic->cpu_mask_to_apicid_and) | ||
8 | #define wakeup_secondary_cpu (apic->wakeup_cpu) | 6 | #define wakeup_secondary_cpu (apic->wakeup_cpu) |
9 | 7 | ||
10 | extern void generic_bigsmp_probe(void); | 8 | extern void generic_bigsmp_probe(void); |
diff --git a/arch/x86/include/asm/numaq/apic.h b/arch/x86/include/asm/numaq/apic.h index 765c4d5124cb..ce95e79f7233 100644 --- a/arch/x86/include/asm/numaq/apic.h +++ b/arch/x86/include/asm/numaq/apic.h | |||
@@ -101,15 +101,16 @@ static inline int numaq_check_phys_apicid_present(int boot_cpu_physical_apicid) | |||
101 | * We use physical apicids here, not logical, so just return the default | 101 | * We use physical apicids here, not logical, so just return the default |
102 | * physical broadcast to stop people from breaking us | 102 | * physical broadcast to stop people from breaking us |
103 | */ | 103 | */ |
104 | static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask) | 104 | static inline unsigned int numaq_cpu_mask_to_apicid(const cpumask_t *cpumask) |
105 | { | 105 | { |
106 | return (int) 0xF; | 106 | return 0x0F; |
107 | } | 107 | } |
108 | 108 | ||
109 | static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *cpumask, | 109 | static inline unsigned int |
110 | const struct cpumask *andmask) | 110 | numaq_cpu_mask_to_apicid_and(const struct cpumask *cpumask, |
111 | const struct cpumask *andmask) | ||
111 | { | 112 | { |
112 | return (int) 0xF; | 113 | return 0x0F; |
113 | } | 114 | } |
114 | 115 | ||
115 | /* No NUMA-Q box has a HT CPU, but it can't hurt to use the default code. */ | 116 | /* No NUMA-Q box has a HT CPU, but it can't hurt to use the default code. */ |
diff --git a/arch/x86/include/asm/summit/apic.h b/arch/x86/include/asm/summit/apic.h index fa6b3b45290d..15b8dbd19e1a 100644 --- a/arch/x86/include/asm/summit/apic.h +++ b/arch/x86/include/asm/summit/apic.h | |||
@@ -125,29 +125,32 @@ static inline int summit_check_phys_apicid_present(int boot_cpu_physical_apicid) | |||
125 | return 1; | 125 | return 1; |
126 | } | 126 | } |
127 | 127 | ||
128 | static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask) | 128 | static inline unsigned int summit_cpu_mask_to_apicid(const cpumask_t *cpumask) |
129 | { | 129 | { |
130 | int num_bits_set; | ||
131 | int cpus_found = 0; | 130 | int cpus_found = 0; |
132 | int cpu; | 131 | int num_bits_set; |
133 | int apicid; | 132 | int apicid; |
133 | int cpu; | ||
134 | 134 | ||
135 | num_bits_set = cpus_weight(*cpumask); | 135 | num_bits_set = cpus_weight(*cpumask); |
136 | /* Return id to all */ | 136 | /* Return id to all */ |
137 | if (num_bits_set >= nr_cpu_ids) | 137 | if (num_bits_set >= nr_cpu_ids) |
138 | return (int) 0xFF; | 138 | return 0xFF; |
139 | /* | 139 | /* |
140 | * The cpus in the mask must all be on the apic cluster. If are not | 140 | * The cpus in the mask must all be on the apic cluster. If are not |
141 | * on the same apicid cluster return default value of target_cpus(): | 141 | * on the same apicid cluster return default value of target_cpus(): |
142 | */ | 142 | */ |
143 | cpu = first_cpu(*cpumask); | 143 | cpu = first_cpu(*cpumask); |
144 | apicid = summit_cpu_to_logical_apicid(cpu); | 144 | apicid = summit_cpu_to_logical_apicid(cpu); |
145 | |||
145 | while (cpus_found < num_bits_set) { | 146 | while (cpus_found < num_bits_set) { |
146 | if (cpu_isset(cpu, *cpumask)) { | 147 | if (cpu_isset(cpu, *cpumask)) { |
147 | int new_apicid = summit_cpu_to_logical_apicid(cpu); | 148 | int new_apicid = summit_cpu_to_logical_apicid(cpu); |
149 | |||
148 | if (apicid_cluster(apicid) != | 150 | if (apicid_cluster(apicid) != |
149 | apicid_cluster(new_apicid)){ | 151 | apicid_cluster(new_apicid)) { |
150 | printk ("%s: Not a valid mask!\n", __func__); | 152 | printk ("%s: Not a valid mask!\n", __func__); |
153 | |||
151 | return 0xFF; | 154 | return 0xFF; |
152 | } | 155 | } |
153 | apicid = apicid | new_apicid; | 156 | apicid = apicid | new_apicid; |
@@ -158,8 +161,9 @@ static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask) | |||
158 | return apicid; | 161 | return apicid; |
159 | } | 162 | } |
160 | 163 | ||
161 | static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *inmask, | 164 | static inline unsigned int |
162 | const struct cpumask *andmask) | 165 | summit_cpu_mask_to_apicid_and(const struct cpumask *inmask, |
166 | const struct cpumask *andmask) | ||
163 | { | 167 | { |
164 | int apicid = summit_cpu_to_logical_apicid(0); | 168 | int apicid = summit_cpu_to_logical_apicid(0); |
165 | cpumask_var_t cpumask; | 169 | cpumask_var_t cpumask; |
@@ -169,9 +173,10 @@ static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *inmask, | |||
169 | 173 | ||
170 | cpumask_and(cpumask, inmask, andmask); | 174 | cpumask_and(cpumask, inmask, andmask); |
171 | cpumask_and(cpumask, cpumask, cpu_online_mask); | 175 | cpumask_and(cpumask, cpumask, cpu_online_mask); |
172 | apicid = cpu_mask_to_apicid(cpumask); | 176 | apicid = summit_cpu_mask_to_apicid(cpumask); |
173 | 177 | ||
174 | free_cpumask_var(cpumask); | 178 | free_cpumask_var(cpumask); |
179 | |||
175 | return apicid; | 180 | return apicid; |
176 | } | 181 | } |
177 | 182 | ||
diff --git a/arch/x86/kernel/genapic_flat_64.c b/arch/x86/kernel/genapic_flat_64.c index 78baa55cd0e9..b941b112cafb 100644 --- a/arch/x86/kernel/genapic_flat_64.c +++ b/arch/x86/kernel/genapic_flat_64.c | |||
@@ -309,11 +309,13 @@ physflat_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | |||
309 | * We're using fixed IRQ delivery, can only return one phys APIC ID. | 309 | * We're using fixed IRQ delivery, can only return one phys APIC ID. |
310 | * May as well be the first. | 310 | * May as well be the first. |
311 | */ | 311 | */ |
312 | for_each_cpu_and(cpu, cpumask, andmask) | 312 | for_each_cpu_and(cpu, cpumask, andmask) { |
313 | if (cpumask_test_cpu(cpu, cpu_online_mask)) | 313 | if (cpumask_test_cpu(cpu, cpu_online_mask)) |
314 | break; | 314 | break; |
315 | } | ||
315 | if (cpu < nr_cpu_ids) | 316 | if (cpu < nr_cpu_ids) |
316 | return per_cpu(x86_cpu_to_apicid, cpu); | 317 | return per_cpu(x86_cpu_to_apicid, cpu); |
318 | |||
317 | return BAD_APICID; | 319 | return BAD_APICID; |
318 | } | 320 | } |
319 | 321 | ||
diff --git a/arch/x86/kernel/genx2apic_cluster.c b/arch/x86/kernel/genx2apic_cluster.c index c7557e051848..62f9fccf01dd 100644 --- a/arch/x86/kernel/genx2apic_cluster.c +++ b/arch/x86/kernel/genx2apic_cluster.c | |||
@@ -111,21 +111,21 @@ static int x2apic_apic_id_registered(void) | |||
111 | 111 | ||
112 | static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask) | 112 | static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask) |
113 | { | 113 | { |
114 | int cpu; | ||
115 | |||
116 | /* | 114 | /* |
117 | * We're using fixed IRQ delivery, can only return one logical APIC ID. | 115 | * We're using fixed IRQ delivery, can only return one logical APIC ID. |
118 | * May as well be the first. | 116 | * May as well be the first. |
119 | */ | 117 | */ |
120 | cpu = cpumask_first(cpumask); | 118 | int cpu = cpumask_first(cpumask); |
119 | |||
121 | if ((unsigned)cpu < nr_cpu_ids) | 120 | if ((unsigned)cpu < nr_cpu_ids) |
122 | return per_cpu(x86_cpu_to_logical_apicid, cpu); | 121 | return per_cpu(x86_cpu_to_logical_apicid, cpu); |
123 | else | 122 | else |
124 | return BAD_APICID; | 123 | return BAD_APICID; |
125 | } | 124 | } |
126 | 125 | ||
127 | static unsigned int x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | 126 | static unsigned int |
128 | const struct cpumask *andmask) | 127 | x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask, |
128 | const struct cpumask *andmask) | ||
129 | { | 129 | { |
130 | int cpu; | 130 | int cpu; |
131 | 131 | ||
@@ -133,11 +133,14 @@ static unsigned int x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | |||
133 | * We're using fixed IRQ delivery, can only return one logical APIC ID. | 133 | * We're using fixed IRQ delivery, can only return one logical APIC ID. |
134 | * May as well be the first. | 134 | * May as well be the first. |
135 | */ | 135 | */ |
136 | for_each_cpu_and(cpu, cpumask, andmask) | 136 | for_each_cpu_and(cpu, cpumask, andmask) { |
137 | if (cpumask_test_cpu(cpu, cpu_online_mask)) | 137 | if (cpumask_test_cpu(cpu, cpu_online_mask)) |
138 | break; | 138 | break; |
139 | } | ||
140 | |||
139 | if (cpu < nr_cpu_ids) | 141 | if (cpu < nr_cpu_ids) |
140 | return per_cpu(x86_cpu_to_logical_apicid, cpu); | 142 | return per_cpu(x86_cpu_to_logical_apicid, cpu); |
143 | |||
141 | return BAD_APICID; | 144 | return BAD_APICID; |
142 | } | 145 | } |
143 | 146 | ||
diff --git a/arch/x86/kernel/genx2apic_phys.c b/arch/x86/kernel/genx2apic_phys.c index 80cba49cfd89..3da1675b2604 100644 --- a/arch/x86/kernel/genx2apic_phys.c +++ b/arch/x86/kernel/genx2apic_phys.c | |||
@@ -110,21 +110,21 @@ static int x2apic_apic_id_registered(void) | |||
110 | 110 | ||
111 | static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask) | 111 | static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask) |
112 | { | 112 | { |
113 | int cpu; | ||
114 | |||
115 | /* | 113 | /* |
116 | * We're using fixed IRQ delivery, can only return one phys APIC ID. | 114 | * We're using fixed IRQ delivery, can only return one phys APIC ID. |
117 | * May as well be the first. | 115 | * May as well be the first. |
118 | */ | 116 | */ |
119 | cpu = cpumask_first(cpumask); | 117 | int cpu = cpumask_first(cpumask); |
118 | |||
120 | if ((unsigned)cpu < nr_cpu_ids) | 119 | if ((unsigned)cpu < nr_cpu_ids) |
121 | return per_cpu(x86_cpu_to_apicid, cpu); | 120 | return per_cpu(x86_cpu_to_apicid, cpu); |
122 | else | 121 | else |
123 | return BAD_APICID; | 122 | return BAD_APICID; |
124 | } | 123 | } |
125 | 124 | ||
126 | static unsigned int x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | 125 | static unsigned int |
127 | const struct cpumask *andmask) | 126 | x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask, |
127 | const struct cpumask *andmask) | ||
128 | { | 128 | { |
129 | int cpu; | 129 | int cpu; |
130 | 130 | ||
@@ -132,11 +132,14 @@ static unsigned int x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | |||
132 | * We're using fixed IRQ delivery, can only return one phys APIC ID. | 132 | * We're using fixed IRQ delivery, can only return one phys APIC ID. |
133 | * May as well be the first. | 133 | * May as well be the first. |
134 | */ | 134 | */ |
135 | for_each_cpu_and(cpu, cpumask, andmask) | 135 | for_each_cpu_and(cpu, cpumask, andmask) { |
136 | if (cpumask_test_cpu(cpu, cpu_online_mask)) | 136 | if (cpumask_test_cpu(cpu, cpu_online_mask)) |
137 | break; | 137 | break; |
138 | } | ||
139 | |||
138 | if (cpu < nr_cpu_ids) | 140 | if (cpu < nr_cpu_ids) |
139 | return per_cpu(x86_cpu_to_apicid, cpu); | 141 | return per_cpu(x86_cpu_to_apicid, cpu); |
142 | |||
140 | return BAD_APICID; | 143 | return BAD_APICID; |
141 | } | 144 | } |
142 | 145 | ||
diff --git a/arch/x86/kernel/genx2apic_uv_x.c b/arch/x86/kernel/genx2apic_uv_x.c index 50310b96adc3..f957878c21e9 100644 --- a/arch/x86/kernel/genx2apic_uv_x.c +++ b/arch/x86/kernel/genx2apic_uv_x.c | |||
@@ -171,21 +171,21 @@ static void uv_init_apic_ldr(void) | |||
171 | 171 | ||
172 | static unsigned int uv_cpu_mask_to_apicid(const struct cpumask *cpumask) | 172 | static unsigned int uv_cpu_mask_to_apicid(const struct cpumask *cpumask) |
173 | { | 173 | { |
174 | int cpu; | ||
175 | |||
176 | /* | 174 | /* |
177 | * We're using fixed IRQ delivery, can only return one phys APIC ID. | 175 | * We're using fixed IRQ delivery, can only return one phys APIC ID. |
178 | * May as well be the first. | 176 | * May as well be the first. |
179 | */ | 177 | */ |
180 | cpu = cpumask_first(cpumask); | 178 | int cpu = cpumask_first(cpumask); |
179 | |||
181 | if ((unsigned)cpu < nr_cpu_ids) | 180 | if ((unsigned)cpu < nr_cpu_ids) |
182 | return per_cpu(x86_cpu_to_apicid, cpu); | 181 | return per_cpu(x86_cpu_to_apicid, cpu); |
183 | else | 182 | else |
184 | return BAD_APICID; | 183 | return BAD_APICID; |
185 | } | 184 | } |
186 | 185 | ||
187 | static unsigned int uv_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | 186 | static unsigned int |
188 | const struct cpumask *andmask) | 187 | uv_cpu_mask_to_apicid_and(const struct cpumask *cpumask, |
188 | const struct cpumask *andmask) | ||
189 | { | 189 | { |
190 | int cpu; | 190 | int cpu; |
191 | 191 | ||
@@ -193,11 +193,13 @@ static unsigned int uv_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | |||
193 | * We're using fixed IRQ delivery, can only return one phys APIC ID. | 193 | * We're using fixed IRQ delivery, can only return one phys APIC ID. |
194 | * May as well be the first. | 194 | * May as well be the first. |
195 | */ | 195 | */ |
196 | for_each_cpu_and(cpu, cpumask, andmask) | 196 | for_each_cpu_and(cpu, cpumask, andmask) { |
197 | if (cpumask_test_cpu(cpu, cpu_online_mask)) | 197 | if (cpumask_test_cpu(cpu, cpu_online_mask)) |
198 | break; | 198 | break; |
199 | } | ||
199 | if (cpu < nr_cpu_ids) | 200 | if (cpu < nr_cpu_ids) |
200 | return per_cpu(x86_cpu_to_apicid, cpu); | 201 | return per_cpu(x86_cpu_to_apicid, cpu); |
202 | |||
201 | return BAD_APICID; | 203 | return BAD_APICID; |
202 | } | 204 | } |
203 | 205 | ||
diff --git a/arch/x86/kernel/io_apic.c b/arch/x86/kernel/io_apic.c index 3d85d3d810b2..01a2505d7275 100644 --- a/arch/x86/kernel/io_apic.c +++ b/arch/x86/kernel/io_apic.c | |||
@@ -563,8 +563,9 @@ static int | |||
563 | assign_irq_vector(int irq, struct irq_cfg *cfg, const struct cpumask *mask); | 563 | assign_irq_vector(int irq, struct irq_cfg *cfg, const struct cpumask *mask); |
564 | 564 | ||
565 | /* | 565 | /* |
566 | * Either sets desc->affinity to a valid value, and returns cpu_mask_to_apicid | 566 | * Either sets desc->affinity to a valid value, and returns |
567 | * of that, or returns BAD_APICID and leaves desc->affinity untouched. | 567 | * ->cpu_mask_to_apicid of that, or returns BAD_APICID and |
568 | * leaves desc->affinity untouched. | ||
568 | */ | 569 | */ |
569 | static unsigned int | 570 | static unsigned int |
570 | set_desc_affinity(struct irq_desc *desc, const struct cpumask *mask) | 571 | set_desc_affinity(struct irq_desc *desc, const struct cpumask *mask) |
@@ -582,7 +583,8 @@ set_desc_affinity(struct irq_desc *desc, const struct cpumask *mask) | |||
582 | 583 | ||
583 | cpumask_and(desc->affinity, cfg->domain, mask); | 584 | cpumask_and(desc->affinity, cfg->domain, mask); |
584 | set_extra_move_desc(desc, mask); | 585 | set_extra_move_desc(desc, mask); |
585 | return cpu_mask_to_apicid_and(desc->affinity, cpu_online_mask); | 586 | |
587 | return apic->cpu_mask_to_apicid_and(desc->affinity, cpu_online_mask); | ||
586 | } | 588 | } |
587 | 589 | ||
588 | static void | 590 | static void |
@@ -1562,7 +1564,7 @@ static void setup_IO_APIC_irq(int apic_id, int pin, unsigned int irq, struct irq | |||
1562 | if (assign_irq_vector(irq, cfg, apic->target_cpus())) | 1564 | if (assign_irq_vector(irq, cfg, apic->target_cpus())) |
1563 | return; | 1565 | return; |
1564 | 1566 | ||
1565 | dest = cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus()); | 1567 | dest = apic->cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus()); |
1566 | 1568 | ||
1567 | apic_printk(APIC_VERBOSE,KERN_DEBUG | 1569 | apic_printk(APIC_VERBOSE,KERN_DEBUG |
1568 | "IOAPIC[%d]: Set routing entry (%d-%d -> 0x%x -> " | 1570 | "IOAPIC[%d]: Set routing entry (%d-%d -> 0x%x -> " |
@@ -1666,7 +1668,7 @@ static void __init setup_timer_IRQ0_pin(unsigned int apic_id, unsigned int pin, | |||
1666 | */ | 1668 | */ |
1667 | entry.dest_mode = apic->irq_dest_mode; | 1669 | entry.dest_mode = apic->irq_dest_mode; |
1668 | entry.mask = 1; /* mask IRQ now */ | 1670 | entry.mask = 1; /* mask IRQ now */ |
1669 | entry.dest = cpu_mask_to_apicid(apic->target_cpus()); | 1671 | entry.dest = apic->cpu_mask_to_apicid(apic->target_cpus()); |
1670 | entry.delivery_mode = apic->irq_delivery_mode; | 1672 | entry.delivery_mode = apic->irq_delivery_mode; |
1671 | entry.polarity = 0; | 1673 | entry.polarity = 0; |
1672 | entry.trigger = 0; | 1674 | entry.trigger = 0; |
@@ -2367,7 +2369,7 @@ migrate_ioapic_irq_desc(struct irq_desc *desc, const struct cpumask *mask) | |||
2367 | 2369 | ||
2368 | set_extra_move_desc(desc, mask); | 2370 | set_extra_move_desc(desc, mask); |
2369 | 2371 | ||
2370 | dest = cpu_mask_to_apicid_and(cfg->domain, mask); | 2372 | dest = apic->cpu_mask_to_apicid_and(cfg->domain, mask); |
2371 | 2373 | ||
2372 | modify_ioapic_rte = desc->status & IRQ_LEVEL; | 2374 | modify_ioapic_rte = desc->status & IRQ_LEVEL; |
2373 | if (modify_ioapic_rte) { | 2375 | if (modify_ioapic_rte) { |
@@ -3270,7 +3272,7 @@ static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq, struct msi_ms | |||
3270 | if (err) | 3272 | if (err) |
3271 | return err; | 3273 | return err; |
3272 | 3274 | ||
3273 | dest = cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus()); | 3275 | dest = apic->cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus()); |
3274 | 3276 | ||
3275 | #ifdef CONFIG_INTR_REMAP | 3277 | #ifdef CONFIG_INTR_REMAP |
3276 | if (irq_remapped(irq)) { | 3278 | if (irq_remapped(irq)) { |
@@ -3708,7 +3710,8 @@ int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev) | |||
3708 | struct ht_irq_msg msg; | 3710 | struct ht_irq_msg msg; |
3709 | unsigned dest; | 3711 | unsigned dest; |
3710 | 3712 | ||
3711 | dest = cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus()); | 3713 | dest = apic->cpu_mask_to_apicid_and(cfg->domain, |
3714 | apic->target_cpus()); | ||
3712 | 3715 | ||
3713 | msg.address_hi = HT_IRQ_HIGH_DEST_ID(dest); | 3716 | msg.address_hi = HT_IRQ_HIGH_DEST_ID(dest); |
3714 | 3717 | ||
@@ -3773,7 +3776,7 @@ int arch_enable_uv_irq(char *irq_name, unsigned int irq, int cpu, int mmr_blade, | |||
3773 | entry->polarity = 0; | 3776 | entry->polarity = 0; |
3774 | entry->trigger = 0; | 3777 | entry->trigger = 0; |
3775 | entry->mask = 0; | 3778 | entry->mask = 0; |
3776 | entry->dest = cpu_mask_to_apicid(eligible_cpu); | 3779 | entry->dest = apic->cpu_mask_to_apicid(eligible_cpu); |
3777 | 3780 | ||
3778 | mmr_pnode = uv_blade_to_pnode(mmr_blade); | 3781 | mmr_pnode = uv_blade_to_pnode(mmr_blade); |
3779 | uv_write_global_mmr64(mmr_pnode, mmr_offset, mmr_value); | 3782 | uv_write_global_mmr64(mmr_pnode, mmr_offset, mmr_value); |
diff --git a/arch/x86/mach-generic/bigsmp.c b/arch/x86/mach-generic/bigsmp.c index ee52c59aa3a4..22c2c7b8e4ab 100644 --- a/arch/x86/mach-generic/bigsmp.c +++ b/arch/x86/mach-generic/bigsmp.c | |||
@@ -94,8 +94,8 @@ struct genapic apic_bigsmp = { | |||
94 | .set_apic_id = NULL, | 94 | .set_apic_id = NULL, |
95 | .apic_id_mask = 0xFF << 24, | 95 | .apic_id_mask = 0xFF << 24, |
96 | 96 | ||
97 | .cpu_mask_to_apicid = cpu_mask_to_apicid, | 97 | .cpu_mask_to_apicid = bigsmp_cpu_mask_to_apicid, |
98 | .cpu_mask_to_apicid_and = cpu_mask_to_apicid_and, | 98 | .cpu_mask_to_apicid_and = bigsmp_cpu_mask_to_apicid_and, |
99 | 99 | ||
100 | .send_IPI_mask = send_IPI_mask, | 100 | .send_IPI_mask = send_IPI_mask, |
101 | .send_IPI_mask_allbutself = NULL, | 101 | .send_IPI_mask_allbutself = NULL, |
diff --git a/arch/x86/mach-generic/default.c b/arch/x86/mach-generic/default.c index e4ed7e6d6263..477ebec16749 100644 --- a/arch/x86/mach-generic/default.c +++ b/arch/x86/mach-generic/default.c | |||
@@ -75,8 +75,8 @@ struct genapic apic_default = { | |||
75 | .set_apic_id = NULL, | 75 | .set_apic_id = NULL, |
76 | .apic_id_mask = 0x0F << 24, | 76 | .apic_id_mask = 0x0F << 24, |
77 | 77 | ||
78 | .cpu_mask_to_apicid = cpu_mask_to_apicid, | 78 | .cpu_mask_to_apicid = default_cpu_mask_to_apicid, |
79 | .cpu_mask_to_apicid_and = cpu_mask_to_apicid_and, | 79 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, |
80 | 80 | ||
81 | .send_IPI_mask = send_IPI_mask, | 81 | .send_IPI_mask = send_IPI_mask, |
82 | .send_IPI_mask_allbutself = NULL, | 82 | .send_IPI_mask_allbutself = NULL, |
diff --git a/arch/x86/mach-generic/es7000.c b/arch/x86/mach-generic/es7000.c index 3d046dec0c9a..d758cf65d736 100644 --- a/arch/x86/mach-generic/es7000.c +++ b/arch/x86/mach-generic/es7000.c | |||
@@ -26,7 +26,7 @@ void __init es7000_update_genapic_to_cluster(void) | |||
26 | 26 | ||
27 | apic->init_apic_ldr = es7000_init_apic_ldr_cluster; | 27 | apic->init_apic_ldr = es7000_init_apic_ldr_cluster; |
28 | 28 | ||
29 | apic->cpu_mask_to_apicid = cpu_mask_to_apicid_cluster; | 29 | apic->cpu_mask_to_apicid = es7000_cpu_mask_to_apicid_cluster; |
30 | } | 30 | } |
31 | 31 | ||
32 | static int probe_es7000(void) | 32 | static int probe_es7000(void) |
@@ -130,8 +130,8 @@ struct genapic apic_es7000 = { | |||
130 | .set_apic_id = NULL, | 130 | .set_apic_id = NULL, |
131 | .apic_id_mask = 0xFF << 24, | 131 | .apic_id_mask = 0xFF << 24, |
132 | 132 | ||
133 | .cpu_mask_to_apicid = cpu_mask_to_apicid, | 133 | .cpu_mask_to_apicid = es7000_cpu_mask_to_apicid, |
134 | .cpu_mask_to_apicid_and = cpu_mask_to_apicid_and, | 134 | .cpu_mask_to_apicid_and = es7000_cpu_mask_to_apicid_and, |
135 | 135 | ||
136 | .send_IPI_mask = send_IPI_mask, | 136 | .send_IPI_mask = send_IPI_mask, |
137 | .send_IPI_mask_allbutself = NULL, | 137 | .send_IPI_mask_allbutself = NULL, |
diff --git a/arch/x86/mach-generic/numaq.c b/arch/x86/mach-generic/numaq.c index a7bf1aa02e1a..eb7d56a521d4 100644 --- a/arch/x86/mach-generic/numaq.c +++ b/arch/x86/mach-generic/numaq.c | |||
@@ -94,8 +94,8 @@ struct genapic apic_numaq = { | |||
94 | .set_apic_id = NULL, | 94 | .set_apic_id = NULL, |
95 | .apic_id_mask = 0x0F << 24, | 95 | .apic_id_mask = 0x0F << 24, |
96 | 96 | ||
97 | .cpu_mask_to_apicid = cpu_mask_to_apicid, | 97 | .cpu_mask_to_apicid = numaq_cpu_mask_to_apicid, |
98 | .cpu_mask_to_apicid_and = cpu_mask_to_apicid_and, | 98 | .cpu_mask_to_apicid_and = numaq_cpu_mask_to_apicid_and, |
99 | 99 | ||
100 | .send_IPI_mask = send_IPI_mask, | 100 | .send_IPI_mask = send_IPI_mask, |
101 | .send_IPI_mask_allbutself = NULL, | 101 | .send_IPI_mask_allbutself = NULL, |
diff --git a/arch/x86/mach-generic/summit.c b/arch/x86/mach-generic/summit.c index a0ae6b910488..8c293055bdf0 100644 --- a/arch/x86/mach-generic/summit.c +++ b/arch/x86/mach-generic/summit.c | |||
@@ -74,8 +74,8 @@ struct genapic apic_summit = { | |||
74 | .set_apic_id = NULL, | 74 | .set_apic_id = NULL, |
75 | .apic_id_mask = 0xFF << 24, | 75 | .apic_id_mask = 0xFF << 24, |
76 | 76 | ||
77 | .cpu_mask_to_apicid = cpu_mask_to_apicid, | 77 | .cpu_mask_to_apicid = summit_cpu_mask_to_apicid, |
78 | .cpu_mask_to_apicid_and = cpu_mask_to_apicid_and, | 78 | .cpu_mask_to_apicid_and = summit_cpu_mask_to_apicid_and, |
79 | 79 | ||
80 | .send_IPI_mask = send_IPI_mask, | 80 | .send_IPI_mask = send_IPI_mask, |
81 | .send_IPI_mask_allbutself = NULL, | 81 | .send_IPI_mask_allbutself = NULL, |