Page MenuHomeFreeBSD

x86: Probe the TSC frequency earlier
ClosedPublic

Authored by markj on Feb 24 2022, 9:03 PM.
Tags
None
Referenced Files
F102947083: D34367.diff
Tue, Nov 19, 2:14 AM
Unknown Object (File)
Sat, Oct 26, 7:57 PM
Unknown Object (File)
Oct 19 2024, 10:26 AM
Unknown Object (File)
Sep 16 2024, 1:38 AM
Unknown Object (File)
Sep 10 2024, 2:52 AM
Unknown Object (File)
Aug 30 2024, 12:19 AM
Unknown Object (File)
Aug 30 2024, 12:18 AM
Unknown Object (File)
Aug 30 2024, 12:18 AM
Subscribers

Details

Summary

This lets us use the TSC to implement early DELAY on modern systems,
limiting the use of the sometimes-unreliable 8254 PIT.

PR: 262155

Diff Detail

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

Event Timeline

markj requested review of this revision.Feb 24 2022, 9:03 PM

If the concern is systems where the i8254 doesn't work, should we change tsc_freq_8254 to be more robust?

If the concern is systems where the i8254 doesn't work, should we change tsc_freq_8254 to be more robust?

On such systems we aren't using the 8254 to calibrate the TSC at all, we get the frequency, or something close to it, from CPUID leaves. The problem I want to address is that DELAY() (e.g., during atkbd probe) uses the 8254 timer until the (early) TSC frequency is known. I can't see any reason not to move early TSC calibration so that it happens even earlier.

This addresses the long delay I experienced on the Framework laptop at the start of boot.

If the concern is systems where the i8254 doesn't work, should we change tsc_freq_8254 to be more robust?

On such systems we aren't using the 8254 to calibrate the TSC at all, we get the frequency, or something close to it, from CPUID leaves.

If you're sure the combination of "broken i8254" and "old CPU" will never happen, sure.

The problem I want to address is that DELAY() (e.g., during atkbd probe) uses the 8254 timer until the (early) TSC frequency is known. I can't see any reason not to move early TSC calibration so that it happens even earlier.

Right, this definitely makes the situation better. If we do run into systems which combine older CPUs with broken i8254s we might want to change tsc_freq_8254 as well, but for now I think it's good to go ahead with this patch.

If the concern is systems where the i8254 doesn't work, should we change tsc_freq_8254 to be more robust?

On such systems we aren't using the 8254 to calibrate the TSC at all, we get the frequency, or something close to it, from CPUID leaves.

If you're sure the combination of "broken i8254" and "old CPU" will never happen, sure.

It's hard to be sure, just an empirical observation.

Looks reasonable to me

This revision is now accepted and ready to land.Feb 25 2022, 4:19 PM

i386: Call finishidentcpu() before clock_init()

This revision now requires review to proceed.Feb 25 2022, 4:51 PM
This revision is now accepted and ready to land.Feb 25 2022, 5:02 PM
This revision was automatically updated to reflect the committed changes.