aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64/kernel/apic.c
diff options
context:
space:
mode:
authorAndi Kleen <ak@suse.de>2006-01-11 16:46:51 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-11 22:05:03 -0500
commit11a8e778c46ee76fc46b0a7fa9d455b5a8e3e19f (patch)
tree2e6d19e5fbb9d686448868bc087673e696b5b4be /arch/x86_64/kernel/apic.c
parent5f1d189f8a87930d62c507800a8ac20b9a185e41 (diff)
[PATCH] x86_64: Some housekeeping in local APIC code
Remove support for obsolete hardware and cleanup. - Remove checks for non integrated APICs - Replace apic_write_around with apic_write. - Remove apic_read_around - Remove APIC version reads used by old workarounds - Remove old workaround for Simics - Fix indentation Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/x86_64/kernel/apic.c')
-rw-r--r--arch/x86_64/kernel/apic.c83
1 files changed, 36 insertions, 47 deletions
diff --git a/arch/x86_64/kernel/apic.c b/arch/x86_64/kernel/apic.c
index c3239f6c22be..8fdd089fd17e 100644
--- a/arch/x86_64/kernel/apic.c
+++ b/arch/x86_64/kernel/apic.c
@@ -53,20 +53,17 @@ static void apic_pm_activate(void);
53 53
54void enable_NMI_through_LVT0 (void * dummy) 54void enable_NMI_through_LVT0 (void * dummy)
55{ 55{
56 unsigned int v, ver; 56 unsigned int v;
57 57
58 ver = apic_read(APIC_LVR);
59 ver = GET_APIC_VERSION(ver);
60 v = APIC_DM_NMI; /* unmask and set to NMI */ 58 v = APIC_DM_NMI; /* unmask and set to NMI */
61 apic_write_around(APIC_LVT0, v); 59 apic_write(APIC_LVT0, v);
62} 60}
63 61
64int get_maxlvt(void) 62int get_maxlvt(void)
65{ 63{
66 unsigned int v, ver, maxlvt; 64 unsigned int v, maxlvt;
67 65
68 v = apic_read(APIC_LVR); 66 v = apic_read(APIC_LVR);
69 ver = GET_APIC_VERSION(v);
70 maxlvt = GET_APIC_MAXLVT(v); 67 maxlvt = GET_APIC_MAXLVT(v);
71 return maxlvt; 68 return maxlvt;
72} 69}
@@ -84,33 +81,33 @@ void clear_local_APIC(void)
84 */ 81 */
85 if (maxlvt >= 3) { 82 if (maxlvt >= 3) {
86 v = ERROR_APIC_VECTOR; /* any non-zero vector will do */ 83 v = ERROR_APIC_VECTOR; /* any non-zero vector will do */
87 apic_write_around(APIC_LVTERR, v | APIC_LVT_MASKED); 84 apic_write(APIC_LVTERR, v | APIC_LVT_MASKED);
88 } 85 }
89 /* 86 /*
90 * Careful: we have to set masks only first to deassert 87 * Careful: we have to set masks only first to deassert
91 * any level-triggered sources. 88 * any level-triggered sources.
92 */ 89 */
93 v = apic_read(APIC_LVTT); 90 v = apic_read(APIC_LVTT);
94 apic_write_around(APIC_LVTT, v | APIC_LVT_MASKED); 91 apic_write(APIC_LVTT, v | APIC_LVT_MASKED);
95 v = apic_read(APIC_LVT0); 92 v = apic_read(APIC_LVT0);
96 apic_write_around(APIC_LVT0, v | APIC_LVT_MASKED); 93 apic_write(APIC_LVT0, v | APIC_LVT_MASKED);
97 v = apic_read(APIC_LVT1); 94 v = apic_read(APIC_LVT1);
98 apic_write_around(APIC_LVT1, v | APIC_LVT_MASKED); 95 apic_write(APIC_LVT1, v | APIC_LVT_MASKED);
99 if (maxlvt >= 4) { 96 if (maxlvt >= 4) {
100 v = apic_read(APIC_LVTPC); 97 v = apic_read(APIC_LVTPC);
101 apic_write_around(APIC_LVTPC, v | APIC_LVT_MASKED); 98 apic_write(APIC_LVTPC, v | APIC_LVT_MASKED);
102 } 99 }
103 100
104 /* 101 /*
105 * Clean APIC state for other OSs: 102 * Clean APIC state for other OSs:
106 */ 103 */
107 apic_write_around(APIC_LVTT, APIC_LVT_MASKED); 104 apic_write(APIC_LVTT, APIC_LVT_MASKED);
108 apic_write_around(APIC_LVT0, APIC_LVT_MASKED); 105 apic_write(APIC_LVT0, APIC_LVT_MASKED);
109 apic_write_around(APIC_LVT1, APIC_LVT_MASKED); 106 apic_write(APIC_LVT1, APIC_LVT_MASKED);
110 if (maxlvt >= 3) 107 if (maxlvt >= 3)
111 apic_write_around(APIC_LVTERR, APIC_LVT_MASKED); 108 apic_write(APIC_LVTERR, APIC_LVT_MASKED);
112 if (maxlvt >= 4) 109 if (maxlvt >= 4)
113 apic_write_around(APIC_LVTPC, APIC_LVT_MASKED); 110 apic_write(APIC_LVTPC, APIC_LVT_MASKED);
114 v = GET_APIC_VERSION(apic_read(APIC_LVR)); 111 v = GET_APIC_VERSION(apic_read(APIC_LVR));
115 apic_write(APIC_ESR, 0); 112 apic_write(APIC_ESR, 0);
116 apic_read(APIC_ESR); 113 apic_read(APIC_ESR);
@@ -155,7 +152,7 @@ void disconnect_bsp_APIC(int virt_wire_setup)
155 value &= ~APIC_VECTOR_MASK; 152 value &= ~APIC_VECTOR_MASK;
156 value |= APIC_SPIV_APIC_ENABLED; 153 value |= APIC_SPIV_APIC_ENABLED;
157 value |= 0xf; 154 value |= 0xf;
158 apic_write_around(APIC_SPIV, value); 155 apic_write(APIC_SPIV, value);
159 156
160 if (!virt_wire_setup) { 157 if (!virt_wire_setup) {
161 /* For LVT0 make it edge triggered, active high, external and enabled */ 158 /* For LVT0 make it edge triggered, active high, external and enabled */
@@ -165,11 +162,11 @@ void disconnect_bsp_APIC(int virt_wire_setup)
165 APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED ); 162 APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED );
166 value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING; 163 value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
167 value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_EXTINT); 164 value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_EXTINT);
168 apic_write_around(APIC_LVT0, value); 165 apic_write(APIC_LVT0, value);
169 } 166 }
170 else { 167 else {
171 /* Disable LVT0 */ 168 /* Disable LVT0 */
172 apic_write_around(APIC_LVT0, APIC_LVT_MASKED); 169 apic_write(APIC_LVT0, APIC_LVT_MASKED);
173 } 170 }
174 171
175 /* For LVT1 make it edge triggered, active high, nmi and enabled */ 172 /* For LVT1 make it edge triggered, active high, nmi and enabled */
@@ -180,7 +177,7 @@ void disconnect_bsp_APIC(int virt_wire_setup)
180 APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED); 177 APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED);
181 value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING; 178 value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
182 value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_NMI); 179 value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_NMI);
183 apic_write_around(APIC_LVT1, value); 180 apic_write(APIC_LVT1, value);
184 } 181 }
185} 182}
186 183
@@ -196,7 +193,7 @@ void disable_local_APIC(void)
196 */ 193 */
197 value = apic_read(APIC_SPIV); 194 value = apic_read(APIC_SPIV);
198 value &= ~APIC_SPIV_APIC_ENABLED; 195 value &= ~APIC_SPIV_APIC_ENABLED;
199 apic_write_around(APIC_SPIV, value); 196 apic_write(APIC_SPIV, value);
200} 197}
201 198
202/* 199/*
@@ -273,7 +270,7 @@ void __init sync_Arb_IDs(void)
273 apic_wait_icr_idle(); 270 apic_wait_icr_idle();
274 271
275 apic_printk(APIC_DEBUG, "Synchronizing Arb IDs.\n"); 272 apic_printk(APIC_DEBUG, "Synchronizing Arb IDs.\n");
276 apic_write_around(APIC_ICR, APIC_DEST_ALLINC | APIC_INT_LEVELTRIG 273 apic_write(APIC_ICR, APIC_DEST_ALLINC | APIC_INT_LEVELTRIG
277 | APIC_DM_INIT); 274 | APIC_DM_INIT);
278} 275}
279 276
@@ -284,7 +281,7 @@ extern void __error_in_apic_c (void);
284 */ 281 */
285void __init init_bsp_APIC(void) 282void __init init_bsp_APIC(void)
286{ 283{
287 unsigned int value, ver; 284 unsigned int value;
288 285
289 /* 286 /*
290 * Don't do the setup now if we have a SMP BIOS as the 287 * Don't do the setup now if we have a SMP BIOS as the
@@ -294,7 +291,6 @@ void __init init_bsp_APIC(void)
294 return; 291 return;
295 292
296 value = apic_read(APIC_LVR); 293 value = apic_read(APIC_LVR);
297 ver = GET_APIC_VERSION(value);
298 294
299 /* 295 /*
300 * Do not trust the local APIC being empty at bootup. 296 * Do not trust the local APIC being empty at bootup.
@@ -309,22 +305,21 @@ void __init init_bsp_APIC(void)
309 value |= APIC_SPIV_APIC_ENABLED; 305 value |= APIC_SPIV_APIC_ENABLED;
310 value |= APIC_SPIV_FOCUS_DISABLED; 306 value |= APIC_SPIV_FOCUS_DISABLED;
311 value |= SPURIOUS_APIC_VECTOR; 307 value |= SPURIOUS_APIC_VECTOR;
312 apic_write_around(APIC_SPIV, value); 308 apic_write(APIC_SPIV, value);
313 309
314 /* 310 /*
315 * Set up the virtual wire mode. 311 * Set up the virtual wire mode.
316 */ 312 */
317 apic_write_around(APIC_LVT0, APIC_DM_EXTINT); 313 apic_write(APIC_LVT0, APIC_DM_EXTINT);
318 value = APIC_DM_NMI; 314 value = APIC_DM_NMI;
319 apic_write_around(APIC_LVT1, value); 315 apic_write(APIC_LVT1, value);
320} 316}
321 317
322void __cpuinit setup_local_APIC (void) 318void __cpuinit setup_local_APIC (void)
323{ 319{
324 unsigned int value, ver, maxlvt; 320 unsigned int value, maxlvt;
325 321
326 value = apic_read(APIC_LVR); 322 value = apic_read(APIC_LVR);
327 ver = GET_APIC_VERSION(value);
328 323
329 if ((SPURIOUS_APIC_VECTOR & 0x0f) != 0x0f) 324 if ((SPURIOUS_APIC_VECTOR & 0x0f) != 0x0f)
330 __error_in_apic_c(); 325 __error_in_apic_c();
@@ -349,7 +344,7 @@ void __cpuinit setup_local_APIC (void)
349 */ 344 */
350 value = apic_read(APIC_TASKPRI); 345 value = apic_read(APIC_TASKPRI);
351 value &= ~APIC_TPRI_MASK; 346 value &= ~APIC_TPRI_MASK;
352 apic_write_around(APIC_TASKPRI, value); 347 apic_write(APIC_TASKPRI, value);
353 348
354 /* 349 /*
355 * Now that we are all set up, enable the APIC 350 * Now that we are all set up, enable the APIC
@@ -391,7 +386,7 @@ void __cpuinit setup_local_APIC (void)
391 * Set spurious IRQ vector 386 * Set spurious IRQ vector
392 */ 387 */
393 value |= SPURIOUS_APIC_VECTOR; 388 value |= SPURIOUS_APIC_VECTOR;
394 apic_write_around(APIC_SPIV, value); 389 apic_write(APIC_SPIV, value);
395 390
396 /* 391 /*
397 * Set up LVT0, LVT1: 392 * Set up LVT0, LVT1:
@@ -411,7 +406,7 @@ void __cpuinit setup_local_APIC (void)
411 value = APIC_DM_EXTINT | APIC_LVT_MASKED; 406 value = APIC_DM_EXTINT | APIC_LVT_MASKED;
412 apic_printk(APIC_VERBOSE, "masked ExtINT on CPU#%d\n", smp_processor_id()); 407 apic_printk(APIC_VERBOSE, "masked ExtINT on CPU#%d\n", smp_processor_id());
413 } 408 }
414 apic_write_around(APIC_LVT0, value); 409 apic_write(APIC_LVT0, value);
415 410
416 /* 411 /*
417 * only the BP should see the LINT1 NMI signal, obviously. 412 * only the BP should see the LINT1 NMI signal, obviously.
@@ -420,14 +415,14 @@ void __cpuinit setup_local_APIC (void)
420 value = APIC_DM_NMI; 415 value = APIC_DM_NMI;
421 else 416 else
422 value = APIC_DM_NMI | APIC_LVT_MASKED; 417 value = APIC_DM_NMI | APIC_LVT_MASKED;
423 apic_write_around(APIC_LVT1, value); 418 apic_write(APIC_LVT1, value);
424 419
425 { 420 {
426 unsigned oldvalue; 421 unsigned oldvalue;
427 maxlvt = get_maxlvt(); 422 maxlvt = get_maxlvt();
428 oldvalue = apic_read(APIC_ESR); 423 oldvalue = apic_read(APIC_ESR);
429 value = ERROR_APIC_VECTOR; // enables sending errors 424 value = ERROR_APIC_VECTOR; // enables sending errors
430 apic_write_around(APIC_LVTERR, value); 425 apic_write(APIC_LVTERR, value);
431 /* 426 /*
432 * spec says clear errors after enabling vector. 427 * spec says clear errors after enabling vector.
433 */ 428 */
@@ -672,17 +667,17 @@ static void __setup_APIC_LVTT(unsigned int clocks)
672 if (cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask)) 667 if (cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask))
673 lvtt_value |= APIC_LVT_MASKED; 668 lvtt_value |= APIC_LVT_MASKED;
674 669
675 apic_write_around(APIC_LVTT, lvtt_value); 670 apic_write(APIC_LVTT, lvtt_value);
676 671
677 /* 672 /*
678 * Divide PICLK by 16 673 * Divide PICLK by 16
679 */ 674 */
680 tmp_value = apic_read(APIC_TDCR); 675 tmp_value = apic_read(APIC_TDCR);
681 apic_write_around(APIC_TDCR, (tmp_value 676 apic_write(APIC_TDCR, (tmp_value
682 & ~(APIC_TDR_DIV_1 | APIC_TDR_DIV_TMBASE)) 677 & ~(APIC_TDR_DIV_1 | APIC_TDR_DIV_TMBASE))
683 | APIC_TDR_DIV_16); 678 | APIC_TDR_DIV_16);
684 679
685 apic_write_around(APIC_TMICT, clocks/APIC_DIVISOR); 680 apic_write(APIC_TMICT, clocks/APIC_DIVISOR);
686} 681}
687 682
688static void setup_APIC_timer(unsigned int clocks) 683static void setup_APIC_timer(unsigned int clocks)
@@ -691,12 +686,6 @@ static void setup_APIC_timer(unsigned int clocks)
691 686
692 local_irq_save(flags); 687 local_irq_save(flags);
693 688
694 /* For some reasons this doesn't work on Simics, so fake it for now */
695 if (!strstr(boot_cpu_data.x86_model_id, "Screwdriver")) {
696 __setup_APIC_LVTT(clocks);
697 return;
698 }
699
700 /* wait for irq slice */ 689 /* wait for irq slice */
701 if (vxtime.hpet_address) { 690 if (vxtime.hpet_address) {
702 int trigger = hpet_readl(HPET_T0_CMP); 691 int trigger = hpet_readl(HPET_T0_CMP);
@@ -709,7 +698,7 @@ static void setup_APIC_timer(unsigned int clocks)
709 outb_p(0x00, 0x43); 698 outb_p(0x00, 0x43);
710 c2 = inb_p(0x40); 699 c2 = inb_p(0x40);
711 c2 |= inb_p(0x40) << 8; 700 c2 |= inb_p(0x40) << 8;
712 do { 701 do {
713 c1 = c2; 702 c1 = c2;
714 outb_p(0x00, 0x43); 703 outb_p(0x00, 0x43);
715 c2 = inb_p(0x40); 704 c2 = inb_p(0x40);
@@ -800,7 +789,7 @@ void disable_APIC_timer(void)
800 unsigned long v; 789 unsigned long v;
801 790
802 v = apic_read(APIC_LVTT); 791 v = apic_read(APIC_LVTT);
803 apic_write_around(APIC_LVTT, v | APIC_LVT_MASKED); 792 apic_write(APIC_LVTT, v | APIC_LVT_MASKED);
804 } 793 }
805} 794}
806 795
@@ -813,7 +802,7 @@ void enable_APIC_timer(void)
813 unsigned long v; 802 unsigned long v;
814 803
815 v = apic_read(APIC_LVTT); 804 v = apic_read(APIC_LVTT);
816 apic_write_around(APIC_LVTT, v & ~APIC_LVT_MASKED); 805 apic_write(APIC_LVTT, v & ~APIC_LVT_MASKED);
817 } 806 }
818} 807}
819 808
@@ -1066,7 +1055,7 @@ int __init APIC_init_uniprocessor (void)
1066 connect_bsp_APIC(); 1055 connect_bsp_APIC();
1067 1056
1068 phys_cpu_present_map = physid_mask_of_physid(boot_cpu_id); 1057 phys_cpu_present_map = physid_mask_of_physid(boot_cpu_id);
1069 apic_write_around(APIC_ID, SET_APIC_ID(boot_cpu_id)); 1058 apic_write(APIC_ID, SET_APIC_ID(boot_cpu_id));
1070 1059
1071 setup_local_APIC(); 1060 setup_local_APIC();
1072 1061