ioapic: Add tunable hw.ioapic_use_old
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Mon, 14 Mar 2011 13:57:14 +0000 (21:57 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Mon, 14 Mar 2011 14:21:01 +0000 (22:21 +0800)
Mainly to ease following new I/O APIC related code testing.

sys/platform/pc32/i386/machdep.c
sys/platform/pc32/i386/mp_machdep.c
sys/platform/pc32/include/smp.h
sys/platform/pc32/isa/clock.c
sys/platform/pc64/include/smp.h
sys/platform/pc64/isa/clock.c
sys/platform/pc64/x86_64/machdep.c
sys/platform/pc64/x86_64/mp_machdep.c

index f017f14..2ebd8c6 100644 (file)
@@ -1876,6 +1876,8 @@ do_next:
 }
 
 #ifdef SMP
+int ioapic_use_old = 1;
+
 #ifdef APIC_IO
 int apic_io_enable = 1; /* Enabled by default for kernels compiled w/APIC_IO */
 #else
@@ -1944,6 +1946,7 @@ init386(int first)
        MachIntrABI = MachIntrABI_ICU;
 #ifdef SMP
        TUNABLE_INT_FETCH("hw.apic_io_enable", &apic_io_enable);
+       TUNABLE_INT_FETCH("hw.ioapic_use_old", &ioapic_use_old);
 #endif
 
        /*
index f6e5828..9059692 100644 (file)
@@ -547,10 +547,12 @@ mp_announce(void)
        }
 
 if (apic_io_enable) {
-       for (x = 0; x < mp_napics; ++x) {
-               kprintf(" io%d (APIC): apic id: %2d", x, IO_TO_ID(x));
-               kprintf(", version: 0x%08x", io_apic_versions[x]);
-               kprintf(", at 0x%08lx\n", io_apic_address[x]);
+       if (ioapic_use_old) {
+               for (x = 0; x < mp_napics; ++x) {
+                       kprintf(" io%d (APIC): apic id: %2d", x, IO_TO_ID(x));
+                       kprintf(", version: 0x%08x", io_apic_versions[x]);
+                       kprintf(", at 0x%08lx\n", io_apic_address[x]);
+               }
        }
 } else {
        kprintf(" Warning: APIC I/O disabled\n");
@@ -653,7 +655,7 @@ mp_enable(u_int boot_addr)
                mptable_imcr(&mpt);
                mptable_unmap(&mpt);
        }
-if (apic_io_enable) {
+if (apic_io_enable && ioapic_use_old) {
 
        if (!mptable_fps_phyaddr)
                panic("no MP table, disable APIC_IO! (set hw.apic_io_enable=0)\n");
index 28cbd9a..bc48ab5 100644 (file)
@@ -160,6 +160,7 @@ void        lapic_enumerator_register(struct lapic_enumerator *);
 void   ioapic_config(void);
 void   ioapic_enumerator_register(struct ioapic_enumerator *);
 extern int apic_io_enable;
+extern int ioapic_use_old;
 
 #if defined(READY)
 void   clr_io_apic_mask24      (int, u_int32_t);
index 71434a2..f8dda81 100644 (file)
@@ -1035,25 +1035,29 @@ i8254_intr_initclock(struct cputimer_intr *cti, boolean_t selected)
        /* Finish initializing 8253 timer 0. */
 #ifdef SMP /* APIC-IO */
 if (apic_io_enable) {
-       apic_8254_intr = isa_apic_irq(0);
-       if (apic_8254_intr >= 0 ) {
-               if (apic_int_type(0, 0) == 3)
-                       apic_8254_trial = 1;
-       } else {
-               /* look for ExtInt on pin 0 */
-               if (apic_int_type(0, 0) == 3) {
-                       apic_8254_intr = apic_irq(0, 0);
-                       setup_8254_mixed_mode();
-               } else 
-                       panic("APIC_IO: Cannot route 8254 interrupt to CPU");
-       }
+       if (ioapic_use_old) {
+               apic_8254_intr = isa_apic_irq(0);
+               if (apic_8254_intr >= 0 ) {
+                       if (apic_int_type(0, 0) == 3)
+                               apic_8254_trial = 1;
+               } else {
+                       /* look for ExtInt on pin 0 */
+                       if (apic_int_type(0, 0) == 3) {
+                               apic_8254_intr = apic_irq(0, 0);
+                               setup_8254_mixed_mode();
+                       } else {
+                               panic("APIC_IO: Cannot route 8254 "
+                                     "interrupt to CPU");
+                       }
+               }
 
-       clkdesc = register_int(apic_8254_intr, clkintr, NULL, "clk",
-                              NULL,
-                              INTR_EXCL | INTR_CLOCK |
-                              INTR_NOPOLL | INTR_MPSAFE | 
-                              INTR_NOENTROPY);
-       machintr_intren(apic_8254_intr);
+               clkdesc = register_int(apic_8254_intr, clkintr, NULL, "clk",
+                                      NULL,
+                                      INTR_EXCL | INTR_CLOCK |
+                                      INTR_NOPOLL | INTR_MPSAFE | 
+                                      INTR_NOENTROPY);
+               machintr_intren(apic_8254_intr);
+       }
 } else {
 #endif
        register_int(0, clkintr, NULL, "clk", NULL,
@@ -1070,7 +1074,7 @@ if (apic_io_enable) {
        writertc(RTC_STATUSB, RTCSB_24HR);
 
 #ifdef SMP /* APIC-IO */
-if (apic_io_enable) {
+if (apic_io_enable && ioapic_use_old) {
        if (apic_8254_trial) {
                sysclock_t base;
                long lastcnt;
index 0079d82..449626c 100644 (file)
@@ -66,6 +66,7 @@ void  ioapic_write            (volatile void *, int, u_int);
 
 /* global data in mp_machdep.c */
 extern int                     apic_io_enable;
+extern int                     ioapic_use_old;
 extern int                     mp_naps;
 extern int                     mp_napics;
 extern vm_offset_t             io_apic_address[];
index ea5a589..ceab3af 100644 (file)
@@ -1042,25 +1042,29 @@ i8254_intr_initclock(struct cputimer_intr *cti, boolean_t selected)
        /* Finish initializing 8254 timer 0. */
 #ifdef SMP /* APIC-IO */
 if (apic_io_enable) {
-       apic_8254_intr = isa_apic_irq(0);
-       if (apic_8254_intr >= 0 ) {
-               if (apic_int_type(0, 0) == 3)
-                       apic_8254_trial = 1;
-       } else {
-               /* look for ExtInt on pin 0 */
-               if (apic_int_type(0, 0) == 3) {
-                       apic_8254_intr = apic_irq(0, 0);
-                       setup_8254_mixed_mode();
-               } else 
-                       panic("APIC_IO: Cannot route 8254 interrupt to CPU");
-       }
+       if (ioapic_use_old) {
+               apic_8254_intr = isa_apic_irq(0);
+               if (apic_8254_intr >= 0 ) {
+                       if (apic_int_type(0, 0) == 3)
+                               apic_8254_trial = 1;
+               } else {
+                       /* look for ExtInt on pin 0 */
+                       if (apic_int_type(0, 0) == 3) {
+                               apic_8254_intr = apic_irq(0, 0);
+                               setup_8254_mixed_mode();
+                       } else {
+                               panic("APIC_IO: Cannot route 8254 "
+                                     "interrupt to CPU");
+                       }
+               }
 
-       clkdesc = register_int(apic_8254_intr, clkintr, NULL, "clk",
-                              NULL,
-                              INTR_EXCL | INTR_CLOCK |
-                              INTR_NOPOLL | INTR_MPSAFE | 
-                              INTR_NOENTROPY);
-       machintr_intren(apic_8254_intr);
+               clkdesc = register_int(apic_8254_intr, clkintr, NULL, "clk",
+                                      NULL,
+                                      INTR_EXCL | INTR_CLOCK |
+                                      INTR_NOPOLL | INTR_MPSAFE | 
+                                      INTR_NOENTROPY);
+               machintr_intren(apic_8254_intr);
+       }
 } else {
 #endif
        register_int(0, clkintr, NULL, "clk", NULL,
@@ -1077,7 +1081,7 @@ if (apic_io_enable) {
        writertc(RTC_STATUSB, RTCSB_24HR);
 
 #ifdef SMP /* APIC-IO */
-if (apic_io_enable) {
+if (apic_io_enable && ioapic_use_old) {
        if (apic_8254_trial) {
                sysclock_t base;
                long lastcnt;
index b86bdb0..99cf8cb 100644 (file)
@@ -1679,6 +1679,8 @@ do_next:
 }
 
 #ifdef SMP
+int ioapic_use_old = 1;
+
 #ifdef APIC_IO
 int apic_io_enable = 1; /* Enabled by default for kernels compiled w/APIC_IO */
 #else
@@ -1771,6 +1773,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
        MachIntrABI = MachIntrABI_ICU;
 #ifdef SMP
        TUNABLE_INT_FETCH("hw.apic_io_enable", &apic_io_enable);
+       TUNABLE_INT_FETCH("hw.ioapic_use_old", &ioapic_use_old);
 #endif
 
        /*
index c23d9c2..0fe0b0a 100644 (file)
@@ -533,10 +533,12 @@ mp_announce(void)
        }
 
 if (apic_io_enable) {
-       for (x = 0; x < mp_napics; ++x) {
-               kprintf(" io%d (APIC): apic id: %2d", x, IO_TO_ID(x));
-               kprintf(", version: 0x%08x", io_apic_versions[x]);
-               kprintf(", at 0x%08lx\n", io_apic_address[x]);
+       if (ioapic_use_old) {
+               for (x = 0; x < mp_napics; ++x) {
+                       kprintf(" io%d (APIC): apic id: %2d", x, IO_TO_ID(x));
+                       kprintf(", version: 0x%08x", io_apic_versions[x]);
+                       kprintf(", at 0x%08lx\n", io_apic_address[x]);
+               }
        }
 } else {
        kprintf(" Warning: APIC I/O disabled\n");
@@ -674,7 +676,7 @@ mp_enable(u_int boot_addr)
                mptable_imcr(&mpt);
                mptable_unmap(&mpt);
        }
-if (apic_io_enable) {
+if (apic_io_enable && ioapic_use_old) {
 
        if (!mptable_fps_phyaddr)
                panic("no MP table, disable APIC_IO! (set hw.apic_io_enable=0)\n");