x86: I/O APIC: AEOI timer acknowledgement clean-ups
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / x86 / kernel / io_apic_32.c
index 4dc8600d9d2072ed5ed79ee3884f70afd2281636..c64b3f5cc121e5f5385e721c993fb1979cc48766 100644 (file)
@@ -2130,10 +2130,14 @@ static inline void __init check_timer(void)
 {
        int apic1, pin1, apic2, pin2;
        int vector;
+       unsigned int ver;
        unsigned long flags;
 
        local_irq_save(flags);
 
+       ver = apic_read(APIC_LVR);
+       ver = GET_APIC_VERSION(ver);
+
        /*
         * get/set the timer IRQ vector:
         */
@@ -2142,15 +2146,17 @@ static inline void __init check_timer(void)
        set_intr_gate(vector, interrupt[0]);
 
        /*
-        * Subtle, code in do_timer_interrupt() expects an AEOI
-        * mode for the 8259A whenever interrupts are routed
-        * through I/O APICs.  Also IRQ0 has to be enabled in
-        * the 8259A which implies the virtual wire has to be
-        * disabled in the local APIC.
+        * As IRQ0 is to be enabled in the 8259A, the virtual
+        * wire has to be disabled in the local APIC.  Also
+        * timer interrupts need to be acknowledged manually in
+        * the 8259A for the i82489DX when using the NMI
+        * watchdog as that APIC treats NMIs as level-triggered.
+        * The AEOI mode will finish them in the 8259A
+        * automatically.
         */
        apic_write_around(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT);
        init_8259A(1);
-       timer_ack = 1;
+       timer_ack = (nmi_watchdog == NMI_IO_APIC && !APIC_INTEGRATED(ver));
        if (timer_over_8254 > 0)
                enable_8259A_irq(0);
 
@@ -2211,6 +2217,7 @@ static inline void __init check_timer(void)
                printk(KERN_WARNING "timer doesn't work through the IO-APIC - disabling NMI Watchdog!\n");
                nmi_watchdog = 0;
        }
+       timer_ack = 0;
 
        printk(KERN_INFO "...trying to set up timer as Virtual Wire IRQ...");
 
@@ -2229,7 +2236,6 @@ static inline void __init check_timer(void)
 
        printk(KERN_INFO "...trying to set up timer as ExtINT IRQ...");
 
-       timer_ack = 0;
        init_8259A(0);
        make_8259A_irq(0);
        apic_write_around(APIC_LVT0, APIC_DM_EXTINT);