Page MenuHomeFreeBSD

Improve TSC calibration logic.
ClosedPublic

Authored by kib on Apr 14 2020, 11:48 PM.
Tags
None
Referenced Files
F81425100: D24426.id70628.diff
Tue, Apr 16, 4:13 AM
Unknown Object (File)
Fri, Apr 12, 7:59 AM
Unknown Object (File)
Wed, Apr 10, 10:35 PM
Unknown Object (File)
Wed, Apr 10, 10:45 AM
Unknown Object (File)
Wed, Apr 10, 10:07 AM
Unknown Object (File)
Mon, Apr 8, 5:27 PM
Unknown Object (File)
Mon, Mar 18, 5:40 AM
Unknown Object (File)
Dec 13 2023, 3:55 AM
Subscribers

Details

Summary

Stop attempting to use FADT legacy hardware flag, it is almost always a lie.

Instead, unless user explicitly disabled the calibration, calibrate against 8254 ISA clock. Then obtain the rough value of the expected TSC frequency from CPUID leafs 0x15/0x16 or even from the CPU marketing name. If calibration results look unbelievably bogus comparing with CPUID leafs report, use CPUID one.

Intel does not recommend to use CPUID leaf 0x16 for the value of the system time frequency, indeed the error there might be up to 1% which e.g. makes ntpd give up. If ISA clock is present, we win, if not, we get some frequency that allows the machine to boot without enormous delay.

Next improvement would be to use HPET for re-calibration if we decided that ISA clock gives bogus results, after HPETs are enumerated. This is a much bigger change since we probably would need to re-evaluate some constants depending on TSC frequency.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib added a reviewer: emaste.

Works on my Icelake system

This revision is now accepted and ready to land.Apr 15 2020, 9:35 PM

Approach seems reasonable to me.

This revision was automatically updated to reflect the committed changes.