diff options
author | attilio <attilio@FreeBSD.org> | 2010-03-03 17:13:29 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2010-03-03 17:13:29 +0000 |
commit | 5de847743136b43bab304d46d1d8ecf43181f28d (patch) | |
tree | 9ce6258d29e2f2d394434668c021bca584aa4c6b /sys/x86 | |
parent | fbccca5923756b5be7a7ca058ec93b316f661c6d (diff) | |
download | FreeBSD-src-5de847743136b43bab304d46d1d8ecf43181f28d.zip FreeBSD-src-5de847743136b43bab304d46d1d8ecf43181f28d.tar.gz |
Improving the clocks auto-tunning by firstly checking if the atrtc may be
correctly initialized and just then assign to softclock/profclock.
Right now, some atrtc seems reporting strange diagnostic error* making the
current pattern bogus.
In order to do that cleanly, lapic_setup_clock(), on both ia32 and amd64,
now accepts as arguments the desired sources to handle, and returns the
actual ones (LAPIC_CLOCK_NONE is forbidden because otherwise there is no
meaning in calling such function).
This allows to bring out into commont x86 code the handling part for
machdep.lapic_allclocks tunable, which is retained.
Sponsored by: Sandvine Incorporated
Tested by: yongari, Richard Todd
<rmtodd at ichotolot dot servalan dot com>
MFC: 3 weeks
X-MFC: r202387, 204309
Diffstat (limited to 'sys/x86')
-rw-r--r-- | sys/x86/isa/clock.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/sys/x86/isa/clock.c b/sys/x86/isa/clock.c index 6ced537..4a20709 100644 --- a/sys/x86/isa/clock.c +++ b/sys/x86/isa/clock.c @@ -97,6 +97,9 @@ TUNABLE_INT("hw.i8254.freq", &i8254_freq); int i8254_max_count; static int i8254_real_max_count; +static int lapic_allclocks; +TUNABLE_INT("machdep.lapic_allclocks", &lapic_allclocks); + struct mtx clock_lock; static struct intsrc *i8254_intsrc; static u_int32_t i8254_lastcount; @@ -526,9 +529,24 @@ startrtclock() void cpu_initclocks() { +#if defined(__amd64__) || defined(DEV_APIC) + enum lapic_clock tlsca; +#endif + int tasc; + + /* Initialize RTC. */ + atrtc_start(); + tasc = atrtc_setup_clock(); + /* + * If the atrtc successfully initialized and the users didn't force + * otherwise use the LAPIC in order to cater hardclock only, otherwise + * take in charge all the clock sources. + */ #if defined(__amd64__) || defined(DEV_APIC) - using_lapic_timer = lapic_setup_clock(); + tlsca = (lapic_allclocks == 0 && tasc != 0) ? LAPIC_CLOCK_HARDCLOCK : + LAPIC_CLOCK_ALL; + using_lapic_timer = lapic_setup_clock(tlsca); #endif /* * If we aren't using the local APIC timer to drive the kernel @@ -550,9 +568,6 @@ cpu_initclocks() set_i8254_freq(i8254_freq, hz); } - /* Initialize RTC. */ - atrtc_start(); - /* * If the separate statistics clock hasn't been explicility disabled * and we aren't already using the local APIC timer to drive the @@ -560,7 +575,7 @@ cpu_initclocks() * drive statclock() and profclock(). */ if (using_lapic_timer != LAPIC_CLOCK_ALL) { - using_atrtc_timer = atrtc_setup_clock(); + using_atrtc_timer = tasc; if (using_atrtc_timer) { /* Enable periodic interrupts from the RTC. */ intr_add_handler("rtc", 8, |