aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/apic.c
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2009-02-17 02:02:14 -0500
committerIngo Molnar <mingo@elte.hu>2009-02-17 06:22:20 -0500
commitc1eeb2de41d7015678bdd412b48a5f071b84e29a (patch)
tree6af99f46f557f9e854e882deac52d23b2fadb5a2 /arch/x86/kernel/apic.c
parent06cd9a7dc8a58186060a91b6ddc031057435fd34 (diff)
x86: fold apic_ops into genapic
Impact: cleanup make it simpler, don't need have one extra struct. v2: fix the sgi_uv build Signed-off-by: Yinghai Lu <yinghai@kernel.org> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/apic.c')
-rw-r--r--arch/x86/kernel/apic.c63
1 files changed, 4 insertions, 59 deletions
diff --git a/arch/x86/kernel/apic.c b/arch/x86/kernel/apic.c
index 004aa1c31e4f..af494bad8858 100644
--- a/arch/x86/kernel/apic.c
+++ b/arch/x86/kernel/apic.c
@@ -210,18 +210,13 @@ static int modern_apic(void)
210 return lapic_get_version() >= 0x14; 210 return lapic_get_version() >= 0x14;
211} 211}
212 212
213/* 213void native_apic_wait_icr_idle(void)
214 * Paravirt kernels also might be using these below ops. So we still
215 * use generic apic_read()/apic_write(), which might be pointing to different
216 * ops in PARAVIRT case.
217 */
218void xapic_wait_icr_idle(void)
219{ 214{
220 while (apic_read(APIC_ICR) & APIC_ICR_BUSY) 215 while (apic_read(APIC_ICR) & APIC_ICR_BUSY)
221 cpu_relax(); 216 cpu_relax();
222} 217}
223 218
224u32 safe_xapic_wait_icr_idle(void) 219u32 native_safe_apic_wait_icr_idle(void)
225{ 220{
226 u32 send_status; 221 u32 send_status;
227 int timeout; 222 int timeout;
@@ -237,13 +232,13 @@ u32 safe_xapic_wait_icr_idle(void)
237 return send_status; 232 return send_status;
238} 233}
239 234
240void xapic_icr_write(u32 low, u32 id) 235void native_apic_icr_write(u32 low, u32 id)
241{ 236{
242 apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(id)); 237 apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(id));
243 apic_write(APIC_ICR, low); 238 apic_write(APIC_ICR, low);
244} 239}
245 240
246static u64 xapic_icr_read(void) 241u64 native_apic_icr_read(void)
247{ 242{
248 u32 icr1, icr2; 243 u32 icr1, icr2;
249 244
@@ -253,54 +248,6 @@ static u64 xapic_icr_read(void)
253 return icr1 | ((u64)icr2 << 32); 248 return icr1 | ((u64)icr2 << 32);
254} 249}
255 250
256static struct apic_ops xapic_ops = {
257 .read = native_apic_mem_read,
258 .write = native_apic_mem_write,
259 .icr_read = xapic_icr_read,
260 .icr_write = xapic_icr_write,
261 .wait_icr_idle = xapic_wait_icr_idle,
262 .safe_wait_icr_idle = safe_xapic_wait_icr_idle,
263};
264
265struct apic_ops __read_mostly *apic_ops = &xapic_ops;
266EXPORT_SYMBOL_GPL(apic_ops);
267
268#ifdef CONFIG_X86_X2APIC
269static void x2apic_wait_icr_idle(void)
270{
271 /* no need to wait for icr idle in x2apic */
272 return;
273}
274
275static u32 safe_x2apic_wait_icr_idle(void)
276{
277 /* no need to wait for icr idle in x2apic */
278 return 0;
279}
280
281void x2apic_icr_write(u32 low, u32 id)
282{
283 wrmsrl(APIC_BASE_MSR + (APIC_ICR >> 4), ((__u64) id) << 32 | low);
284}
285
286static u64 x2apic_icr_read(void)
287{
288 unsigned long val;
289
290 rdmsrl(APIC_BASE_MSR + (APIC_ICR >> 4), val);
291 return val;
292}
293
294static struct apic_ops x2apic_ops = {
295 .read = native_apic_msr_read,
296 .write = native_apic_msr_write,
297 .icr_read = x2apic_icr_read,
298 .icr_write = x2apic_icr_write,
299 .wait_icr_idle = x2apic_wait_icr_idle,
300 .safe_wait_icr_idle = safe_x2apic_wait_icr_idle,
301};
302#endif
303
304/** 251/**
305 * enable_NMI_through_LVT0 - enable NMI through local vector table 0 252 * enable_NMI_through_LVT0 - enable NMI through local vector table 0
306 */ 253 */
@@ -1329,7 +1276,6 @@ void check_x2apic(void)
1329 if (msr & X2APIC_ENABLE) { 1276 if (msr & X2APIC_ENABLE) {
1330 pr_info("x2apic enabled by BIOS, switching to x2apic ops\n"); 1277 pr_info("x2apic enabled by BIOS, switching to x2apic ops\n");
1331 x2apic_preenabled = x2apic = 1; 1278 x2apic_preenabled = x2apic = 1;
1332 apic_ops = &x2apic_ops;
1333 } 1279 }
1334} 1280}
1335 1281
@@ -1403,7 +1349,6 @@ void __init enable_IR_x2apic(void)
1403 1349
1404 if (!x2apic) { 1350 if (!x2apic) {
1405 x2apic = 1; 1351 x2apic = 1;
1406 apic_ops = &x2apic_ops;
1407 enable_x2apic(); 1352 enable_x2apic();
1408 } 1353 }
1409 1354