Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:arch\x86\kernel\tsc.c Create Date:2022-07-28 07:46:22
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:alibrate cpu using pit, hpet, and ptimer methods. They are available* later in boot after acpi is initialized.

Proto:static unsigned long pit_hpet_ptimer_calibrate_cpu(void)

Type:unsigned long

Parameter:Nothing

712  tsc_pit_min = ULONG_MAX , tsc_ref_min = ULONG_MAX
714  hpet = is_hpet_enabled()
742  latch = CAL_LATCH
743  ms = CAL_MS
744  loopmin = CAL_PIT_LOOPS
746  When i < 3 cycle
755  local_irq_save(flags)
756  tsc1 = Read TSC and the reference counters. Take care of any disturbances
757  tsc_pit_khz = Try to calibrate the TSC against the Programmable* Interrupt Timer and return the frequency of the TSC* in kHz.* Return ULONG_MAX on failure to calibrate.
758  tsc2 = Read TSC and the reference counters. Take care of any disturbances
759  local_irq_restore(flags)
762  tsc_pit_min = min - return minimum of two values of the same or compatible types*@x: first value*@y: second value(tsc_pit_min, tsc_pit_khz)
765  If ref1 == ref2 Then Continue
769  If tsc1 == ULLONG_MAX || tsc2 == ULLONG_MAX Then Continue
772  tsc2 = (tsc2 - tsc1) * 1000000LL
773  If hpet Then tsc2 = Calculate the TSC frequency from HPET reference
775  Else tsc2 = Calculate the TSC frequency from PMTimer reference
778  tsc_ref_min = min - return minimum of two values of the same or compatible types*@x: first value*@y: second value(tsc_ref_min, (unsignedlong)tsc2)
781  delta = tsc_pit_min * 100
782  do_div() is NOT a C function(delta, tsc_ref_min)
790  If delta >= 90 && delta <= 110 Then
791  pr_info("PIT calibration matches %s. %d loops\n", hpet ? "HPET" : "PMTIMER", i + 1)
793  Return tsc_ref_min
802  If i == 1 && tsc_pit_min == ULONG_MAX Then
803  latch = CAL2_LATCH
804  ms = CAL2_MS
812  If tsc_pit_min == ULONG_MAX Then
814  pr_warn("Unable to calibrate against PIT\n")
817  If Not hpet && Not ref1 && Not ref2 Then
818  pr_notice("No reference (HPET/PMTIMER) available\n")
819  Return 0
823  If tsc_ref_min == ULONG_MAX Then
824  pr_warn("HPET/PMTIMER calibration failed\n")
825  Return 0
829  pr_info("using %s reference calibration\n", hpet ? "HPET" : "PMTIMER")
832  Return tsc_ref_min
836  If Not hpet && Not ref1 && Not ref2 Then
837  pr_info("Using PIT calibration value\n")
838  Return tsc_pit_min
842  If tsc_ref_min == ULONG_MAX Then
843  pr_warn("HPET/PMTIMER calibration failed. Using PIT calibration.\n")
844  Return tsc_pit_min
852  pr_warn("PIT calibration deviates from %s: %lu %lu\n", hpet ? "HPET" : "PMTIMER", tsc_pit_min, tsc_ref_min)
854  pr_info("Using PIT calibration value\n")
855  Return tsc_pit_min
Caller
NameDescribe
native_calibrate_cpuative_calibrate_cpu - calibrate the cpu
determine_cpu_tsc_frequencies