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/include/asm | |
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/include/asm')
-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 |
6 files changed, 49 insertions, 41 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 | ||