summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_clocksource.c
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2010-07-20 15:48:29 +0000
committermav <mav@FreeBSD.org>2010-07-20 15:48:29 +0000
commit0ea74c96a2f40bc01acfd1e4eaff94f73860e331 (patch)
tree2c5e8d78cfbbe53e780bacd903f0ccd75cd9597a /sys/kern/kern_clocksource.c
parente1bb40d4c52c58d39b2ef9cf56223c4419e7bd99 (diff)
downloadFreeBSD-src-0ea74c96a2f40bc01acfd1e4eaff94f73860e331.zip
FreeBSD-src-0ea74c96a2f40bc01acfd1e4eaff94f73860e331.tar.gz
Fix several un-/signedness bugs of r210290 and r210293. Add one more check.
Diffstat (limited to 'sys/kern/kern_clocksource.c')
-rw-r--r--sys/kern/kern_clocksource.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/kern_clocksource.c b/sys/kern/kern_clocksource.c
index 9656db6..6b005de 100644
--- a/sys/kern/kern_clocksource.c
+++ b/sys/kern/kern_clocksource.c
@@ -299,14 +299,14 @@ round_freq(struct eventtimer *et, int freq)
uint64_t div;
if (et->et_frequency != 0) {
- div = (et->et_frequency + freq / 2) / freq;
+ div = lmax((et->et_frequency + freq / 2) / freq, 1);
if (et->et_flags & ET_FLAGS_POW2DIV)
div = 1 << (flsl(div + div / 2) - 1);
freq = (et->et_frequency + div / 2) / div;
}
if (et->et_min_period.sec > 0)
freq = 0;
- else if (et->et_max_period.frac != 0)
+ else if (et->et_min_period.frac != 0)
freq = min(freq, BT2FREQ(&et->et_min_period));
if (et->et_max_period.sec == 0 && et->et_max_period.frac != 0)
freq = max(freq, BT2FREQ(&et->et_max_period));
@@ -365,6 +365,7 @@ cpu_initclocks_bsp(void)
stathz = round_freq(timer[1], 127);
profhz = round_freq(timer[1], stathz * 64);
}
+ tick = 1000000 / hz;
ET_LOCK();
cpu_restartclocks();
ET_UNLOCK();
OpenPOWER on IntegriCloud