aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64/kernel/io_apic.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/kernel/io_apic.c')
-rw-r--r--arch/x86_64/kernel/io_apic.c124
1 files changed, 51 insertions, 73 deletions
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
index f71461b1f03d..88fcc4ebbf6e 100644
--- a/arch/x86_64/kernel/io_apic.c
+++ b/arch/x86_64/kernel/io_apic.c
@@ -55,10 +55,6 @@ int sis_apic_bug; /* not actually supported, dummy for compile */
55 55
56static int no_timer_check; 56static int no_timer_check;
57 57
58static int disable_timer_pin_1 __initdata;
59
60int timer_over_8254 __initdata = 1;
61
62/* Where if anywhere is the i8259 connect in external int mode */ 58/* Where if anywhere is the i8259 connect in external int mode */
63static struct { int pin, apic; } ioapic_i8259 = { -1, -1 }; 59static struct { int pin, apic; } ioapic_i8259 = { -1, -1 };
64 60
@@ -348,29 +344,6 @@ static int __init disable_ioapic_setup(char *str)
348} 344}
349early_param("noapic", disable_ioapic_setup); 345early_param("noapic", disable_ioapic_setup);
350 346
351/* Actually the next is obsolete, but keep it for paranoid reasons -AK */
352static int __init disable_timer_pin_setup(char *arg)
353{
354 disable_timer_pin_1 = 1;
355 return 1;
356}
357__setup("disable_timer_pin_1", disable_timer_pin_setup);
358
359static int __init setup_disable_8254_timer(char *s)
360{
361 timer_over_8254 = -1;
362 return 1;
363}
364static int __init setup_enable_8254_timer(char *s)
365{
366 timer_over_8254 = 2;
367 return 1;
368}
369
370__setup("disable_8254_timer", setup_disable_8254_timer);
371__setup("enable_8254_timer", setup_enable_8254_timer);
372
373
374/* 347/*
375 * Find the IRQ entry number of a certain pin. 348 * Find the IRQ entry number of a certain pin.
376 */ 349 */
@@ -1579,10 +1552,33 @@ static inline void unlock_ExtINT_logic(void)
1579 * a wide range of boards and BIOS bugs. Fortunately only the timer IRQ 1552 * a wide range of boards and BIOS bugs. Fortunately only the timer IRQ
1580 * is so screwy. Thanks to Brian Perkins for testing/hacking this beast 1553 * is so screwy. Thanks to Brian Perkins for testing/hacking this beast
1581 * fanatically on his truly buggy board. 1554 * fanatically on his truly buggy board.
1582 *
1583 * FIXME: really need to revamp this for modern platforms only.
1584 */ 1555 */
1585static inline void check_timer(void) 1556
1557static int try_apic_pin(int apic, int pin, char *msg)
1558{
1559 apic_printk(APIC_VERBOSE, KERN_INFO
1560 "..TIMER: trying IO-APIC=%d PIN=%d %s",
1561 apic, pin, msg);
1562
1563 /*
1564 * Ok, does IRQ0 through the IOAPIC work?
1565 */
1566 if (!no_timer_check && timer_irq_works()) {
1567 nmi_watchdog_default();
1568 if (nmi_watchdog == NMI_IO_APIC) {
1569 disable_8259A_irq(0);
1570 setup_nmi();
1571 enable_8259A_irq(0);
1572 }
1573 return 1;
1574 }
1575 clear_IO_APIC_pin(apic, pin);
1576 apic_printk(APIC_QUIET, KERN_ERR " .. failed\n");
1577 return 0;
1578}
1579
1580/* The function from hell */
1581static void check_timer(void)
1586{ 1582{
1587 int apic1, pin1, apic2, pin2; 1583 int apic1, pin1, apic2, pin2;
1588 int vector; 1584 int vector;
@@ -1603,61 +1599,43 @@ static inline void check_timer(void)
1603 */ 1599 */
1604 apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT); 1600 apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT);
1605 init_8259A(1); 1601 init_8259A(1);
1606 if (timer_over_8254 > 0)
1607 enable_8259A_irq(0);
1608 1602
1609 pin1 = find_isa_irq_pin(0, mp_INT); 1603 pin1 = find_isa_irq_pin(0, mp_INT);
1610 apic1 = find_isa_irq_apic(0, mp_INT); 1604 apic1 = find_isa_irq_apic(0, mp_INT);
1611 pin2 = ioapic_i8259.pin; 1605 pin2 = ioapic_i8259.pin;
1612 apic2 = ioapic_i8259.apic; 1606 apic2 = ioapic_i8259.apic;
1613 1607
1614 apic_printk(APIC_VERBOSE,KERN_INFO "..TIMER: vector=0x%02X apic1=%d pin1=%d apic2=%d pin2=%d\n", 1608 /* Do this first, otherwise we get double interrupts on ATI boards */
1615 vector, apic1, pin1, apic2, pin2); 1609 if ((pin1 != -1) && try_apic_pin(apic1, pin1,"with 8259 IRQ0 disabled"))
1610 return;
1616 1611
1617 if (pin1 != -1) { 1612 /* Now try again with IRQ0 8259A enabled.
1618 /* 1613 Assumes timer is on IO-APIC 0 ?!? */
1619 * Ok, does IRQ0 through the IOAPIC work? 1614 enable_8259A_irq(0);
1620 */ 1615 unmask_IO_APIC_irq(0);
1621 unmask_IO_APIC_irq(0); 1616 if (try_apic_pin(apic1, pin1, "with 8259 IRQ0 enabled"))
1622 if (!no_timer_check && timer_irq_works()) { 1617 return;
1623 nmi_watchdog_default(); 1618 disable_8259A_irq(0);
1624 if (nmi_watchdog == NMI_IO_APIC) {
1625 disable_8259A_irq(0);
1626 setup_nmi();
1627 enable_8259A_irq(0);
1628 }
1629 if (disable_timer_pin_1 > 0)
1630 clear_IO_APIC_pin(0, pin1);
1631 return;
1632 }
1633 clear_IO_APIC_pin(apic1, pin1);
1634 apic_printk(APIC_QUIET,KERN_ERR "..MP-BIOS bug: 8254 timer not "
1635 "connected to IO-APIC\n");
1636 }
1637 1619
1638 apic_printk(APIC_VERBOSE,KERN_INFO "...trying to set up timer (IRQ0) " 1620 /* Always try pin0 and pin2 on APIC 0 to handle buggy timer overrides
1639 "through the 8259A ... "); 1621 on Nvidia boards */
1622 if (!(apic1 == 0 && pin1 == 0) &&
1623 try_apic_pin(0, 0, "fallback with 8259 IRQ0 disabled"))
1624 return;
1625 if (!(apic1 == 0 && pin1 == 2) &&
1626 try_apic_pin(0, 2, "fallback with 8259 IRQ0 disabled"))
1627 return;
1628
1629 /* Then try pure 8259A routing on the 8259 as reported by BIOS*/
1630 enable_8259A_irq(0);
1640 if (pin2 != -1) { 1631 if (pin2 != -1) {
1641 apic_printk(APIC_VERBOSE,"\n..... (found apic %d pin %d) ...",
1642 apic2, pin2);
1643 /*
1644 * legacy devices should be connected to IO APIC #0
1645 */
1646 setup_ExtINT_IRQ0_pin(apic2, pin2, vector); 1632 setup_ExtINT_IRQ0_pin(apic2, pin2, vector);
1647 if (timer_irq_works()) { 1633 if (try_apic_pin(apic2,pin2,"8259A broadcast ExtINT from BIOS"))
1648 apic_printk(APIC_VERBOSE," works.\n");
1649 nmi_watchdog_default();
1650 if (nmi_watchdog == NMI_IO_APIC) {
1651 setup_nmi();
1652 }
1653 return; 1634 return;
1654 }
1655 /*
1656 * Cleanup, just in case ...
1657 */
1658 clear_IO_APIC_pin(apic2, pin2);
1659 } 1635 }
1660 apic_printk(APIC_VERBOSE," failed.\n"); 1636
1637 /* Tried all possibilities to go through the IO-APIC. Now come the
1638 really cheesy fallbacks. */
1661 1639
1662 if (nmi_watchdog == NMI_IO_APIC) { 1640 if (nmi_watchdog == NMI_IO_APIC) {
1663 printk(KERN_WARNING "timer doesn't work through the IO-APIC - disabling NMI Watchdog!\n"); 1641 printk(KERN_WARNING "timer doesn't work through the IO-APIC - disabling NMI Watchdog!\n");