git: 7299cefe3949 - stable/13 - Skip TSC calibration if exact value known

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Sun, 16 Jan 2022 05:34:20 UTC
The branch stable/13 has been updated by cperciva:

URL: https://cgit.FreeBSD.org/src/commit/?id=7299cefe39493490b378ead0118ed2dbe3d36ebb

commit 7299cefe39493490b378ead0118ed2dbe3d36ebb
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2021-12-30 19:43:15 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2022-01-16 05:33:33 +0000

    Skip TSC calibration if exact value known
    
    It's possible that the "early" TSC calibration gave us a value which
    is known to be exact; in that case, skip the later re-calibration.
    
    Differential Revision:  https://reviews.freebsd.org/D33695
    
    (cherry picked from commit 9cb3288287ba1b3c1d0ec891c552fc4b9472027e)
---
 sys/x86/x86/tsc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/x86/x86/tsc.c b/sys/x86/x86/tsc.c
index b752ad18f058..7c4375979b3d 100644
--- a/sys/x86/x86/tsc.c
+++ b/sys/x86/x86/tsc.c
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
 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_vmware(void)
 			tsc_freq = regs[0] | ((uint64_t)regs[1] << 32);
 	}
 	tsc_is_invariant = 1;
+	tsc_early_calib_exact = 1;
 }
 
 /*
@@ -707,6 +709,8 @@ tsc_calibrate(void)
 
 	if (tsc_disabled)
 		return;
+	if (tsc_early_calib_exact)
+		goto calibrated;
 
 	/*
 	 * Avoid using a low-quality timecounter to re-calibrate.  In