This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / arch / i386 / kernel / io_apic.c
index 3ea997f..70f329e 100644 (file)
 
 #include "io_ports.h"
 
-#undef APIC_LOCKUP_DEBUG
-
-#define APIC_LOCKUP_DEBUG
-
 static spinlock_t ioapic_lock = SPIN_LOCK_UNLOCKED;
 
 /*
@@ -127,83 +123,47 @@ static void __init replace_pin_at_irq(unsigned int irq,
        }
 }
 
-/* mask = 1 */
-static void __mask_IO_APIC_irq (unsigned int irq)
+static void __modify_IO_APIC_irq (unsigned int irq, unsigned long enable, unsigned long disable)
 {
-       int pin;
        struct irq_pin_list *entry = irq_2_pin + irq;
+       unsigned int pin, reg;
 
        for (;;) {
-               unsigned int reg;
                pin = entry->pin;
                if (pin == -1)
                        break;
                reg = io_apic_read(entry->apic, 0x10 + pin*2);
-               io_apic_modify(entry->apic, 0x10 + pin*2, reg |= 0x00010000);
+               reg &= ~disable;
+               reg |= enable;
+               io_apic_modify(entry->apic, 0x10 + pin*2, reg);
                if (!entry->next)
                        break;
                entry = irq_2_pin + entry->next;
        }
-       io_apic_sync(entry->apic);
+}
+
+/* mask = 1 */
+static void __mask_IO_APIC_irq (unsigned int irq)
+{
+       __modify_IO_APIC_irq(irq, 0x00010000, 0);
 }
 
 /* mask = 0 */
 static void __unmask_IO_APIC_irq (unsigned int irq)
 {
-       int pin;
-       struct irq_pin_list *entry = irq_2_pin + irq;
-
-       for (;;) {
-               unsigned int reg;
-               pin = entry->pin;
-               if (pin == -1)
-                       break;
-               reg = io_apic_read(entry->apic, 0x10 + pin*2);
-               io_apic_modify(entry->apic, 0x10 + pin*2, reg &= 0xfffeffff);
-               if (!entry->next)
-                       break;
-               entry = irq_2_pin + entry->next;
-       }
+       __modify_IO_APIC_irq(irq, 0, 0x00010000);
 }
 
 /* mask = 1, trigger = 0 */
 static void __mask_and_edge_IO_APIC_irq (unsigned int irq)
 {
-       int pin;
-       struct irq_pin_list *entry = irq_2_pin + irq;
-
-       for (;;) {
-               unsigned int reg;
-               pin = entry->pin;
-               if (pin == -1)
-                       break;
-               reg = io_apic_read(entry->apic, 0x10 + pin*2);
-               reg = (reg & 0xffff7fff) | 0x00010000;
-               io_apic_modify(entry->apic, 0x10 + pin*2, reg);
-               if (!entry->next)
-                       break;
-               entry = irq_2_pin + entry->next;
-       }
+       __modify_IO_APIC_irq(irq, 0x00010000, 0x00008000);
 }
 
 /* mask = 0, trigger = 1 */
 static void __unmask_and_level_IO_APIC_irq (unsigned int irq)
 {
-       int pin;
-       struct irq_pin_list *entry = irq_2_pin + irq;
-
-       for (;;) {
-               unsigned int reg;
-               pin = entry->pin;
-               if (pin == -1)
-                       break;
-               reg = io_apic_read(entry->apic, 0x10 + pin*2);
-               reg = (reg & 0xfffeffff) | 0x00008000;
-               io_apic_modify(entry->apic, 0x10 + pin*2, reg);
-               if (!entry->next)
-                       break;
-               entry = irq_2_pin + entry->next;
-       }
+       __modify_IO_APIC_irq(irq, 0x00008000, 0x00010000);
 }
 
 static void mask_IO_APIC_irq (unsigned int irq)
@@ -1366,7 +1326,7 @@ void __init print_IO_APIC(void)
        printk(KERN_DEBUG ".......    : physical APIC id: %02X\n", reg_00.bits.ID);
        printk(KERN_DEBUG ".......    : Delivery Type: %X\n", reg_00.bits.delivery_type);
        printk(KERN_DEBUG ".......    : LTS          : %X\n", reg_00.bits.LTS);
-       if (reg_00.bits.ID >= APIC_BROADCAST_ID)
+       if (reg_00.bits.ID >= get_physical_broadcast())
                UNEXPECTED_IO_APIC();
        if (reg_00.bits.__reserved_1 || reg_00.bits.__reserved_2)
                UNEXPECTED_IO_APIC();
@@ -1682,7 +1642,7 @@ static void __init setup_ioapic_ids_from_mpc(void)
                
                old_id = mp_ioapics[apic].mpc_apicid;
 
-               if (mp_ioapics[apic].mpc_apicid >= APIC_BROADCAST_ID) {
+               if (mp_ioapics[apic].mpc_apicid >= get_physical_broadcast()) {
                        printk(KERN_ERR "BIOS bug, IO-APIC#%d ID is %d in the MPC table!...\n",
                                apic, mp_ioapics[apic].mpc_apicid);
                        printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n",
@@ -1703,10 +1663,10 @@ static void __init setup_ioapic_ids_from_mpc(void)
                                        mp_ioapics[apic].mpc_apicid)) {
                        printk(KERN_ERR "BIOS bug, IO-APIC#%d ID %d is already used!...\n",
                                apic, mp_ioapics[apic].mpc_apicid);
-                       for (i = 0; i < APIC_BROADCAST_ID; i++)
+                       for (i = 0; i < get_physical_broadcast(); i++)
                                if (!physid_isset(i, phys_id_present_map))
                                        break;
-                       if (i >= APIC_BROADCAST_ID)
+                       if (i >= get_physical_broadcast())
                                panic("Max APIC ID exceeded!\n");
                        printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n",
                                i);
@@ -1893,30 +1853,11 @@ static void end_level_ioapic_irq (unsigned int irq)
        ack_APIC_irq();
 
        if (!(v & (1 << (i & 0x1f)))) {
-#ifdef APIC_LOCKUP_DEBUG
-               struct irq_pin_list *entry;
-#endif
-
 #ifdef APIC_MISMATCH_DEBUG
                atomic_inc(&irq_mis_count);
 #endif
                spin_lock(&ioapic_lock);
                __mask_and_edge_IO_APIC_irq(irq);
-#ifdef APIC_LOCKUP_DEBUG
-               for (entry = irq_2_pin + irq;;) {
-                       unsigned int reg;
-
-                       if (entry->pin == -1)
-                               break;
-                       reg = io_apic_read(entry->apic, 0x10 + entry->pin * 2);
-                       if (reg & 0x00004000)
-                               printk(KERN_CRIT "Aieee!!!  Remote IRR"
-                                       " still set after unlock!\n");
-                       if (!entry->next)
-                               break;
-                       entry = irq_2_pin + entry->next;
-               }
-#endif
                __unmask_and_level_IO_APIC_irq(irq);
                spin_unlock(&ioapic_lock);
        }
@@ -2322,8 +2263,6 @@ late_initcall(io_apic_bug_finalize);
 
 #ifdef CONFIG_ACPI_BOOT
 
-#define IO_APIC_MAX_ID APIC_BROADCAST_ID
-
 int __init io_apic_get_unique_id (int ioapic, int apic_id)
 {
        union IO_APIC_reg_00 reg_00;
@@ -2348,7 +2287,7 @@ int __init io_apic_get_unique_id (int ioapic, int apic_id)
        reg_00.raw = io_apic_read(ioapic, 0);
        spin_unlock_irqrestore(&ioapic_lock, flags);
 
-       if (apic_id >= IO_APIC_MAX_ID) {
+       if (apic_id >= get_physical_broadcast()) {
                printk(KERN_WARNING "IOAPIC[%d]: Invalid apic_id %d, trying "
                        "%d\n", ioapic, apic_id, reg_00.bits.ID);
                apic_id = reg_00.bits.ID;
@@ -2360,12 +2299,12 @@ int __init io_apic_get_unique_id (int ioapic, int apic_id)
         */
        if (check_apicid_used(apic_id_map, apic_id)) {
 
-               for (i = 0; i < IO_APIC_MAX_ID; i++) {
+               for (i = 0; i < get_physical_broadcast(); i++) {
                        if (!check_apicid_used(apic_id_map, i))
                                break;
                }
 
-               if (i == IO_APIC_MAX_ID)
+               if (i == get_physical_broadcast())
                        panic("Max apic_id exceeded!\n");
 
                printk(KERN_WARNING "IOAPIC[%d]: apic_id %d already used, "