From 0d863fd0eb5d49f76c9d3506f52d30d9572565e2 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Mon, 14 Mar 2011 21:57:14 +0800 Subject: [PATCH] ioapic: Add tunable hw.ioapic_use_old Mainly to ease following new I/O APIC related code testing. --- sys/platform/pc32/i386/machdep.c | 3 ++ sys/platform/pc32/i386/mp_machdep.c | 12 ++++---- sys/platform/pc32/include/smp.h | 1 + sys/platform/pc32/isa/clock.c | 42 +++++++++++++++------------ sys/platform/pc64/include/smp.h | 1 + sys/platform/pc64/isa/clock.c | 42 +++++++++++++++------------ sys/platform/pc64/x86_64/machdep.c | 3 ++ sys/platform/pc64/x86_64/mp_machdep.c | 12 ++++---- 8 files changed, 68 insertions(+), 48 deletions(-) diff --git a/sys/platform/pc32/i386/machdep.c b/sys/platform/pc32/i386/machdep.c index f017f1482d..2ebd8c699d 100644 --- a/sys/platform/pc32/i386/machdep.c +++ b/sys/platform/pc32/i386/machdep.c @@ -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 /* diff --git a/sys/platform/pc32/i386/mp_machdep.c b/sys/platform/pc32/i386/mp_machdep.c index f6e582888e..905969294e 100644 --- a/sys/platform/pc32/i386/mp_machdep.c +++ b/sys/platform/pc32/i386/mp_machdep.c @@ -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"); diff --git a/sys/platform/pc32/include/smp.h b/sys/platform/pc32/include/smp.h index 28cbd9aaa7..bc48ab51af 100644 --- a/sys/platform/pc32/include/smp.h +++ b/sys/platform/pc32/include/smp.h @@ -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); diff --git a/sys/platform/pc32/isa/clock.c b/sys/platform/pc32/isa/clock.c index 71434a2de9..f8dda816e9 100644 --- a/sys/platform/pc32/isa/clock.c +++ b/sys/platform/pc32/isa/clock.c @@ -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; diff --git a/sys/platform/pc64/include/smp.h b/sys/platform/pc64/include/smp.h index 0079d82025..449626c81c 100644 --- a/sys/platform/pc64/include/smp.h +++ b/sys/platform/pc64/include/smp.h @@ -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[]; diff --git a/sys/platform/pc64/isa/clock.c b/sys/platform/pc64/isa/clock.c index ea5a5895cd..ceab3afb10 100644 --- a/sys/platform/pc64/isa/clock.c +++ b/sys/platform/pc64/isa/clock.c @@ -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; diff --git a/sys/platform/pc64/x86_64/machdep.c b/sys/platform/pc64/x86_64/machdep.c index b86bdb0974..99cf8cbb42 100644 --- a/sys/platform/pc64/x86_64/machdep.c +++ b/sys/platform/pc64/x86_64/machdep.c @@ -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 /* diff --git a/sys/platform/pc64/x86_64/mp_machdep.c b/sys/platform/pc64/x86_64/mp_machdep.c index c23d9c239d..0fe0b0afa1 100644 --- a/sys/platform/pc64/x86_64/mp_machdep.c +++ b/sys/platform/pc64/x86_64/mp_machdep.c @@ -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"); -- 2.41.0