aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@openvz.org>2009-04-12 12:47:41 -0400
committerIngo Molnar <mingo@elte.hu>2009-04-12 13:23:53 -0400
commit08306ce61d6848e6fbf74fa4cc693c3fb29e943f (patch)
treef61e7f9061e5fa11447b5ab7fd473bfe8985bb99 /arch
parentc0eaa4536f08b98fbcfa7fce5b7b0de1bebcb0e1 (diff)
x86: apic - introduce dummy apic operations
Impact: refactor, speed up and robustize code In case if apic was disabled by kernel option or by hardware limits we can use dummy operations in apic->write to simplify the ack_APIC_irq() code. At the lame time the patch fixes the missed EOI in do_IRQ function (which has place if kernel is compiled as X86-32 and interrupt without handler happens where apic was not asked to be disabled via kernel option). Note that native_apic_write_dummy() consists of WARN_ON_ONCE to catch any buggy writes on enabled APICs. Could be removed after some time of testing. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> LKML-Reference: <20090412165058.724788431@openvz.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/include/asm/apic.h3
-rw-r--r--arch/x86/kernel/apic/apic.c24
-rw-r--r--arch/x86/kernel/irq.c10
3 files changed, 28 insertions, 9 deletions
diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index 42f2f8377422..2bd5a463fd1f 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -212,6 +212,7 @@ static inline void ack_x2APIC_irq(void)
212} 212}
213#endif 213#endif
214 214
215extern void apic_disable(void);
215extern int lapic_get_maxlvt(void); 216extern int lapic_get_maxlvt(void);
216extern void clear_local_APIC(void); 217extern void clear_local_APIC(void);
217extern void connect_bsp_APIC(void); 218extern void connect_bsp_APIC(void);
@@ -252,7 +253,7 @@ static inline void lapic_shutdown(void) { }
252#define local_apic_timer_c2_ok 1 253#define local_apic_timer_c2_ok 1
253static inline void init_apic_mappings(void) { } 254static inline void init_apic_mappings(void) { }
254static inline void disable_local_APIC(void) { } 255static inline void disable_local_APIC(void) { }
255 256static inline void apic_disable(void) { }
256#endif /* !CONFIG_X86_LOCAL_APIC */ 257#endif /* !CONFIG_X86_LOCAL_APIC */
257 258
258#ifdef CONFIG_X86_64 259#ifdef CONFIG_X86_64
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index c3be10f5773e..9b849d4957dc 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -232,6 +232,24 @@ static int modern_apic(void)
232 return lapic_get_version() >= 0x14; 232 return lapic_get_version() >= 0x14;
233} 233}
234 234
235/*
236 * bare function to substitute write operation
237 * and it's _that_ fast :)
238 */
239void native_apic_write_dummy(u32 reg, u32 v)
240{
241 WARN_ON_ONCE((cpu_has_apic || !disable_apic));
242}
243
244/*
245 * right after this call apic->write doesn't do anything
246 * note that there is no restore operation it works one way
247 */
248void apic_disable(void)
249{
250 apic->write = native_apic_write_dummy;
251}
252
235void native_apic_wait_icr_idle(void) 253void native_apic_wait_icr_idle(void)
236{ 254{
237 while (apic_read(APIC_ICR) & APIC_ICR_BUSY) 255 while (apic_read(APIC_ICR) & APIC_ICR_BUSY)
@@ -1582,6 +1600,12 @@ void __init init_apic_mappings(void)
1582 */ 1600 */
1583 if (boot_cpu_physical_apicid == -1U) 1601 if (boot_cpu_physical_apicid == -1U)
1584 boot_cpu_physical_apicid = read_apic_id(); 1602 boot_cpu_physical_apicid = read_apic_id();
1603
1604 /* lets check if we may to NOP'ify apic operations */
1605 if (!cpu_has_apic) {
1606 pr_info("APIC: disable apic facility\n");
1607 apic_disable();
1608 }
1585} 1609}
1586 1610
1587/* 1611/*
diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
index 6603492e8b71..fd57bf35d0fc 100644
--- a/arch/x86/kernel/irq.c
+++ b/arch/x86/kernel/irq.c
@@ -27,7 +27,6 @@ void ack_bad_irq(unsigned int irq)
27 if (printk_ratelimit()) 27 if (printk_ratelimit())
28 pr_err("unexpected IRQ trap at vector %02x\n", irq); 28 pr_err("unexpected IRQ trap at vector %02x\n", irq);
29 29
30#ifdef CONFIG_X86_LOCAL_APIC
31 /* 30 /*
32 * Currently unexpected vectors happen only on SMP and APIC. 31 * Currently unexpected vectors happen only on SMP and APIC.
33 * We _must_ ack these because every local APIC has only N 32 * We _must_ ack these because every local APIC has only N
@@ -37,9 +36,7 @@ void ack_bad_irq(unsigned int irq)
37 * completely. 36 * completely.
38 * But only ack when the APIC is enabled -AK 37 * But only ack when the APIC is enabled -AK
39 */ 38 */
40 if (cpu_has_apic) 39 ack_APIC_irq();
41 ack_APIC_irq();
42#endif
43} 40}
44 41
45#define irq_stats(x) (&per_cpu(irq_stat, x)) 42#define irq_stats(x) (&per_cpu(irq_stat, x))
@@ -214,10 +211,7 @@ unsigned int __irq_entry do_IRQ(struct pt_regs *regs)
214 irq = __get_cpu_var(vector_irq)[vector]; 211 irq = __get_cpu_var(vector_irq)[vector];
215 212
216 if (!handle_irq(irq, regs)) { 213 if (!handle_irq(irq, regs)) {
217#ifdef CONFIG_X86_64 214 ack_APIC_irq();
218 if (!disable_apic)
219 ack_APIC_irq();
220#endif
221 215
222 if (printk_ratelimit()) 216 if (printk_ratelimit())
223 pr_emerg("%s: %d.%d No irq handler for vector (irq %d)\n", 217 pr_emerg("%s: %d.%d No irq handler for vector (irq %d)\n",