From afe41f2da792a35d5b5fe86cb0abe65a93b1fdb0 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Tue, 21 Sep 2010 16:50:24 +0000 Subject: [PATCH] Remember last kern.eventtimer.periodic value, explicitly set by user. If timer capabilities forcing us to change periodicity mode, try to restore it back later, as soon as new choosen timer capable to do it. Without this, timer change like HPET->RTC->HPET always results in enabling periodic mode. --- sys/kern/kern_clocksource.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_clocksource.c b/sys/kern/kern_clocksource.c index eb20a4068503..455564b61979 100644 --- a/sys/kern/kern_clocksource.c +++ b/sys/kern/kern_clocksource.c @@ -117,7 +117,8 @@ SYSCTL_INT(_kern_eventtimer, OID_AUTO, idletick, CTLFLAG_RW, &idletick, 0, "Run periodic events when idle"); static int periodic = 0; /* Periodic or one-shot mode. */ -TUNABLE_INT("kern.eventtimer.periodic", &periodic); +static int want_periodic = 0; /* What mode to prefer. */ +TUNABLE_INT("kern.eventtimer.periodic", &want_periodic); struct pcpu_state { struct mtx et_hw_mtx; /* Per-CPU timer mutex. */ @@ -587,6 +588,7 @@ cpu_initclocks_bsp(void) #ifdef SMP callout_new_inserted = cpu_new_callout; #endif + periodic = want_periodic; /* Grab requested timer or the best of present. */ if (timername[0]) timer = et_find(timername, 0, 0); @@ -841,6 +843,7 @@ sysctl_kern_eventtimer_timer(SYSCTL_HANDLER_ARGS) cpu_disable_deep_sleep++; if (timer->et_flags & ET_FLAGS_C3STOP) cpu_disable_deep_sleep--; + periodic = want_periodic; timer = et; et_init(timer, timercb, NULL, NULL); configtimer(1); @@ -865,7 +868,7 @@ sysctl_kern_eventtimer_periodic(SYSCTL_HANDLER_ARGS) return (error); ET_LOCK(); configtimer(0); - periodic = val; + periodic = want_periodic = val; configtimer(1); ET_UNLOCK(); return (error);