mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
xen/cpu: round cpu_khz calculations
All arches truncate the cpu_khz without taking into account the less significant digits. Instead use DIV_ROUND() when scaling from Hz to kHz to get as more accurate kHz value. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
1 parent
305c6b901a
commit
986707b461
3 files changed
+4
-4
No files matched your search
+2
-2
@@ -118,7 +118,7 @@ static void __init preinit_dt_xen_time(void)
|
||||
res = dt_property_read_u32(timer, "clock-frequency", &rate);
|
||||
if ( res )
|
||||
{
|
||||
cpu_khz = rate / 1000;
|
||||
cpu_khz = DIV_ROUND(rate, 1000);
|
||||
validate_timer_frequency();
|
||||
timer_dt_clock_frequency = rate;
|
||||
}
|
||||
@@ -136,7 +136,7 @@ void __init preinit_xen_time(void)
|
||||
|
||||
if ( !cpu_khz )
|
||||
{
|
||||
cpu_khz = (READ_SYSREG(CNTFRQ_EL0) & CNTFRQ_MASK) / 1000;
|
||||
cpu_khz = DIV_ROUND(READ_SYSREG(CNTFRQ_EL0) & CNTFRQ_MASK, 1000);
|
||||
validate_timer_frequency();
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ static void __init preinit_dt_xen_time(void)
|
||||
if ( !dt_property_read_u32(timer, "timebase-frequency", &rate) )
|
||||
panic("Unable to find clock frequency\n");
|
||||
|
||||
cpu_khz = rate / 1000;
|
||||
cpu_khz = DIV_ROUND(rate, 1000);
|
||||
}
|
||||
|
||||
int reprogram_timer(s_time_t timeout)
|
||||
|
||||
+1
-1
@@ -2642,7 +2642,7 @@ void __init early_time_init(void)
|
||||
set_time_scale(&t->tsc_scale, tmp);
|
||||
t->stamp.local_tsc = boot_tsc_stamp;
|
||||
|
||||
cpu_khz = tmp / 1000;
|
||||
cpu_khz = DIV_ROUND(tmp, 1000);
|
||||
printk("Detected %lu.%03lu MHz processor.\n",
|
||||
cpu_khz / 1000, cpu_khz % 1000);
|
||||
|
||||
|
||||