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:		22875f8879 ("x86: Implement deferred TSC calibration")
Reported and tested by:	mike@sentex.net, Stefan Hegnauer <stefan.hegnauer@gmx.ch>
Reviewed by:	imp, kib
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33730
This commit is contained in:
Mark Johnston 2022-01-03 10:14:41 -05:00
parent 5ba4192565
commit 0e494a9e3f

View File

@ -714,7 +714,14 @@ tsc_calibrate(void)
if (tsc_early_calib_exact)
goto calibrated;
/*
* 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;