git: 08161fd3b207 - stable/13 - x86: Skip late calibration if our reference timer has low quality
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 06 Jan 2022 13:46:48 UTC
The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=08161fd3b207105847bdd1dd8729ea4cbda6e537 commit 08161fd3b207105847bdd1dd8729ea4cbda6e537 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2022-01-03 15:14:41 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2022-01-06 13:46:33 +0000 x86: Skip late calibration if our reference timer has low quality Some AMD Geode-based systems end up using the 8254 PIT to calibrate the TSC during late calibration, which doesn't work because that timecounter's mask (65535) is much smaller than its frequency (1193182). Moreover, early calibration is done against the 8254 timer anyway. Work around the problem by simply using early calibration results if no high-quality timecounters exist. PR: 260868 Fixes: 22875f88799e ("x86: Implement deferred TSC calibration") Reported and tested by: mike@sentex.net, Stefan Hegnauer <stefan.hegnauer@gmx.ch> Reviewed by: imp, kib Sponsored by: The FreeBSD Foundation (cherry picked from commit 0e494a9e3fd86ef54899dcbe0268866629096c1e) --- sys/x86/x86/tsc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/x86/x86/tsc.c b/sys/x86/x86/tsc.c index 6debe3ecca6d..6f0ef697cb2f 100644 --- a/sys/x86/x86/tsc.c +++ b/sys/x86/x86/tsc.c @@ -708,7 +708,14 @@ tsc_calibrate(void) if (tsc_disabled) return; + /* + * Avoid using a low-quality timecounter to re-calibrate. In + * particular, old 32-bit platforms might only have the 8254 timer to + * calibrate against. + */ tc = atomic_load_ptr(&timecounter); + if (tc->tc_quality <= 0) + goto calibrated; flags = intr_disable(); cpu = curcpu;