Page MenuHomeFreeBSD

x86: Skip late calibration if our reference timer has low quality
ClosedPublic

Authored by markj on Jan 3 2022, 3:21 PM.
Tags
None
Referenced Files
F95975082: D33730.id100888.diff
Mon, Sep 23, 5:16 AM
Unknown Object (File)
Tue, Sep 17, 4:14 AM
Unknown Object (File)
Mon, Sep 16, 10:35 PM
Unknown Object (File)
Sun, Sep 8, 2:51 AM
Unknown Object (File)
Sat, Sep 7, 11:01 PM
Unknown Object (File)
Thu, Sep 5, 10:33 AM
Unknown Object (File)
Aug 10 2024, 11:05 AM
Unknown Object (File)
Aug 8 2024, 6:43 AM
Subscribers

Details

Summary

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>

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 43685
Build 40573: arc lint + arc unit

Event Timeline

markj requested review of this revision.Jan 3 2022, 3:21 PM
This revision is now accepted and ready to land.Jan 3 2022, 3:23 PM

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.

Hmm, not sure this makes perfect sense. Even if we end up using the i8254 here, a 1000 ms delay will give us a more accurate calibration than a 100 ms delay... notwithstanding the issues with the timer overflowing, of course.

Once I redo the calibration code (soon, hopefully!) this overflow issue should go away and then I think this can be removed.

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.

Hmm, not sure this makes perfect sense. Even if we end up using the i8254 here, a 1000 ms delay will give us a more accurate calibration than a 100 ms delay...

Might be that we should use a 1000ms delay on i386 to mitigate this. In practice (i.e., on the two systems where the problem was reported and for which I have dmesgs), the difference in calibrated frequencies is reasonably small: 16.5KHz where the reported frequency is 498.06MHz.

notwithstanding the issues with the timer overflowing, of course.

Once I redo the calibration code (soon, hopefully!) this overflow issue should go away and then I think this can be removed.

That'd be fine with me. As you note this change is a bit of a hack; I'm comfortable with it since we almost always have a high-quality timecounter available to calibrate against anyway, but an approach which avoids the overflow is better.