PowerPC: Switch to more accurate unit to avoid division rounding
On POWER8 architecture there is a timer with 512Mhz frequency. It has about 1,95ns period, but it is rounded to 1ns which is not accurate. Submitted by: Patryk Duda <pdk@semihalf.com> Obtained from: Semihalf Reviewed by: wma Sponsored by: IBM, QCM Technologies Differential revision: https://reviews.freebsd.org/D14433
This commit is contained in:
parent
838070d5f4
commit
f32ebdc85c
@ -82,7 +82,7 @@ __FBSDID("$FreeBSD$");
|
||||
* Initially we assume a processor with a bus frequency of 12.5 MHz.
|
||||
*/
|
||||
static int initialized = 0;
|
||||
static u_long ns_per_tick = 80;
|
||||
static uint64_t ps_per_tick = 80000;
|
||||
static u_long ticks_per_sec = 12500000;
|
||||
static u_long *decr_counts[MAXCPU];
|
||||
|
||||
@ -178,7 +178,7 @@ decr_init(void)
|
||||
if (platform_smp_get_bsp(&cpu) != 0)
|
||||
platform_smp_first_cpu(&cpu);
|
||||
ticks_per_sec = platform_timebase_freq(&cpu);
|
||||
ns_per_tick = 1000000000 / ticks_per_sec;
|
||||
ps_per_tick = 1000000000000 / ticks_per_sec;
|
||||
|
||||
set_cputicker(mftb, ticks_per_sec, 0);
|
||||
snprintf(buf, sizeof(buf), "cpu%d:decrementer", curcpu);
|
||||
@ -307,7 +307,7 @@ DELAY(int n)
|
||||
|
||||
TSENTER();
|
||||
tb = mftb();
|
||||
ttb = tb + howmany(n * 1000, ns_per_tick);
|
||||
ttb = tb + howmany((uint64_t)n * 1000000, ps_per_tick);
|
||||
while (tb < ttb)
|
||||
tb = mftb();
|
||||
TSEXIT();
|
||||
|
Loading…
x
Reference in New Issue
Block a user