Page MenuHomeFreeBSD

x86: Probe the TSC frequency earlier
ClosedPublic

Authored by markj on Feb 24 2022, 9:03 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 9, 10:09 PM
Unknown Object (File)
Feb 23 2024, 4:29 PM
Unknown Object (File)
Feb 12 2024, 1:48 AM
Unknown Object (File)
Feb 5 2024, 2:11 PM
Unknown Object (File)
Dec 28 2023, 4:38 AM
Unknown Object (File)
Dec 20 2023, 2:32 AM
Unknown Object (File)
Dec 12 2023, 5:51 AM
Unknown Object (File)
Nov 13 2023, 4:29 PM
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 44578
Build 41466: 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.