diff --git a/sys/x86/x86/tsc.c b/sys/x86/x86/tsc.c --- a/sys/x86/x86/tsc.c +++ b/sys/x86/x86/tsc.c @@ -59,6 +59,7 @@ uint64_t tsc_freq; int tsc_is_invariant; int tsc_perf_stat; +static int tsc_early_calib_exact; static eventhandler_tag tsc_levels_tag, tsc_pre_tag, tsc_post_tag; @@ -133,6 +134,7 @@ tsc_freq = regs[0] | ((uint64_t)regs[1] << 32); } tsc_is_invariant = 1; + tsc_early_calib_exact = 1; } /* @@ -709,6 +711,8 @@ if (tsc_disabled) return; + if (tsc_early_calib_exact) + goto calibrated; tc = atomic_load_ptr(&timecounter); @@ -739,6 +743,7 @@ freq_khz = tc->tc_frequency * (tsc_end - tsc_start) / (t_end - t_start); tsc_update_freq(freq_khz); +calibrated: tc_init(&tsc_timecounter); set_cputicker(rdtsc, tsc_freq, !tsc_is_invariant); }