ioapic: Let callers of pin_setup() to hold imen_spinlock
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 20 Mar 2011 04:15:34 +0000 (12:15 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 20 Mar 2011 04:15:34 +0000 (12:15 +0800)
sys/platform/pc32/apic/ioapic_abi.c
sys/platform/pc32/apic/mpapic.c
sys/platform/pc64/apic/ioapic_abi.c
sys/platform/pc64/apic/mpapic.c

index 9c1a350..bd1be50 100644 (file)
@@ -694,6 +694,8 @@ ioapic_abi_set_irqmap(int irq, int gsi, enum intr_trigger trig,
 
        info = &int_to_apicintpin[irq];
 
+       imen_lock();
+
        info->ioapic = 0; /* XXX unused */
        info->int_pin = pin;
        info->apic_address = ioaddr;
@@ -704,6 +706,8 @@ ioapic_abi_set_irqmap(int irq, int gsi, enum intr_trigger trig,
 
        ioapic_pin_setup(ioaddr, pin, IDT_OFFSET + irq,
            map->im_trig, map->im_pola);
+
+       imen_unlock();
 }
 
 static void
@@ -764,12 +768,16 @@ ioapic_intr_config(int irq, enum intr_trigger trig, enum intr_polarity pola)
 
        info = &int_to_apicintpin[irq];
 
+       imen_lock();
+
        info->flags &= ~IOAPIC_IM_FLAG_LEVEL;
        if (map->im_trig == INTR_TRIGGER_LEVEL)
                info->flags |= IOAPIC_IM_FLAG_LEVEL;
 
        ioapic_pin_setup(ioaddr, pin, IDT_OFFSET + irq,
            map->im_trig, map->im_pola);
+
+       imen_unlock();
 }
 
 #endif /* SMP */
index 19f1dda..c29a3dc 100644 (file)
@@ -1308,8 +1308,10 @@ ioapic_gsi_setup(int gsi)
 
        if (gsi == 0) {
                /* ExtINT */
+               imen_lock();
                ioapic_extpin_setup(ioapic_gsi_ioaddr(gsi),
                    ioapic_gsi_pin(gsi), 0);
+               imen_unlock();
                return;
        }
 
@@ -1369,10 +1371,8 @@ ioapic_gsi_search(int gsi)
 void
 ioapic_extpin_setup(void *addr, int pin, int vec)
 {
-       imen_lock();
        ioapic_pin_prog(addr, pin, vec,
            INTR_TRIGGER_CONFORM, INTR_POLARITY_CONFORM, IOART_DELEXINT);
-       imen_unlock();
 }
 
 void
@@ -1391,13 +1391,9 @@ ioapic_pin_setup(void *addr, int pin, int vec,
         * clear IRR so we can later, safely program it as a level 
         * interrupt.
         */
-       imen_lock();
-
        ioapic_pin_prog(addr, pin, vec, INTR_TRIGGER_EDGE, INTR_POLARITY_HIGH,
            IOART_DELFIXED);
        ioapic_pin_prog(addr, pin, vec, trig, pola, IOART_DELFIXED);
-
-       imen_unlock();
 }
 
 static void
index e2f81a8..de135b3 100644 (file)
@@ -687,6 +687,8 @@ ioapic_abi_set_irqmap(int irq, int gsi, enum intr_trigger trig,
 
        info = &int_to_apicintpin[irq];
 
+       imen_lock();
+
        info->ioapic = 0; /* XXX unused */
        info->int_pin = pin;
        info->apic_address = ioaddr;
@@ -697,6 +699,8 @@ ioapic_abi_set_irqmap(int irq, int gsi, enum intr_trigger trig,
 
        ioapic_pin_setup(ioaddr, pin, IDT_OFFSET + irq,
            map->im_trig, map->im_pola);
+
+       imen_unlock();
 }
 
 static void
@@ -757,12 +761,16 @@ ioapic_intr_config(int irq, enum intr_trigger trig, enum intr_polarity pola)
 
        info = &int_to_apicintpin[irq];
 
+       imen_lock();
+
        info->flags &= ~IOAPIC_IM_FLAG_LEVEL;
        if (map->im_trig == INTR_TRIGGER_LEVEL)
                info->flags |= IOAPIC_IM_FLAG_LEVEL;
 
        ioapic_pin_setup(ioaddr, pin, IDT_OFFSET + irq,
            map->im_trig, map->im_pola);
+
+       imen_unlock();
 }
 
 #endif /* SMP */
index f7a39be..8244af3 100644 (file)
@@ -1370,8 +1370,10 @@ ioapic_gsi_setup(int gsi)
 
        if (gsi == 0) {
                /* ExtINT */
+               imen_lock();
                ioapic_extpin_setup(ioapic_gsi_ioaddr(gsi),
                    ioapic_gsi_pin(gsi), 0);
+               imen_unlock();
                return;
        }
 
@@ -1431,10 +1433,8 @@ ioapic_gsi_search(int gsi)
 void
 ioapic_extpin_setup(void *addr, int pin, int vec)
 {
-       imen_lock();
        ioapic_pin_prog(addr, pin, vec,
            INTR_TRIGGER_CONFORM, INTR_POLARITY_CONFORM, IOART_DELEXINT);
-       imen_unlock();
 }
 
 void
@@ -1453,13 +1453,9 @@ ioapic_pin_setup(void *addr, int pin, int vec,
         * clear IRR so we can later, safely program it as a level 
         * interrupt.
         */
-       imen_lock();
-
        ioapic_pin_prog(addr, pin, vec, INTR_TRIGGER_EDGE, INTR_POLARITY_HIGH,
            IOART_DELFIXED);
        ioapic_pin_prog(addr, pin, vec, trig, pola, IOART_DELFIXED);
-
-       imen_unlock();
 }
 
 static void