Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:arch\x86\kernel\apic\apic.c Create Date:2022-07-28 08:26:56
Last Modify:2020-03-16 21:21:31 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:calibrate_APIC_clock

Proto:static int __init calibrate_APIC_clock(void)

Type:int

Parameter:Nothing

866  levt = this_cpu_ptr( & lapic_events)
867  tsc_perj = 0 , tsc_start = 0
871  pm_referenced = 0
873  If boot_cpu_has(TSC deadline timer ) Then Return 0
881  If Not lapic_init_clockevent() Then
882  Define the default level of output to be very little* This can be turned up by using apic=verbose for more* information and apic=debug for _lots_ of information.* apic_verbosity is defined in apic.c(APIC_VERBOSE, "lapic timer already calibrated %d\n", lapic_timer_period)
888  features &= ~CLOCK_EVT_FEAT_DUMMY
889  Return 0
892  Define the default level of output to be very little* This can be turned up by using apic=verbose for more* information and apic=debug for _lots_ of information.* apic_verbosity is defined in apic.c(APIC_VERBOSE, "Using local APIC timer interrupts.\ncalibrating APIC timer ...\n")
900  local_irq_disable()
906  This function sets up the local APIC timer, with a timeout of* 'clocks' APIC bus clock. During calibration we actually call* this function twice on the boot CPU, once with a bogus timeout* value, second time for real. The other (noncalibrating) CPUs
913  jif_start = READ_ONCE(jiffies)
915  If tsc_khz Then
916  tsc_start = dtsc() - returns the current TSC without ordering constraints* rdtsc() returns the result of RDTSC as a 64-bit integer
917  tsc_perj = div_u64 - unsigned 64bit divide with 32bit divisor*@dividend: unsigned 64bit dividend*@divisor: unsigned 32bit divisor* This is the most common 64bit divide and should be used if possible,* as many 32bit archs can optimize this variant better than a full
924  The local_irq_*() APIs are equal to the raw_local_irq*()* if !TRACE_IRQFLAGS.()
926  When lapic_cal_loops <= In this functions we calibrate APIC bus clocks to the external timer cycle
928  When 1 cycle
929  If tsc_khz Then
935  Else
943  cpu_relax()
947  local_irq_disable()
948  Temporary interrupt handler and polled calibration function.
949  The local_irq_*() APIs are equal to the raw_local_irq*()* if !TRACE_IRQFLAGS.()
952  local_irq_disable()
955  delta = lapic_cal_t1 - lapic_cal_t2
956  Define the default level of output to be very little* This can be turned up by using apic=verbose for more* information and apic=debug for _lots_ of information.* apic_verbosity is defined in apic.c(APIC_VERBOSE, "... lapic delta = %ld\n", delta)
958  deltatsc = lapic_cal_tsc2 - lapic_cal_tsc1
961  pm_referenced = Not calibrate_by_pmtimer(lapic_cal_pm2 - lapic_cal_pm1, & delta, & deltatsc)
964  lapic_timer_period = delta * Clock divisor / In this functions we calibrate APIC bus clocks to the external timer
965  lapic_init_clockevent()
967  Define the default level of output to be very little* This can be turned up by using apic=verbose for more* information and apic=debug for _lots_ of information.* apic_verbosity is defined in apic.c(APIC_VERBOSE, "..... delta %ld\n", delta)
968  Define the default level of output to be very little* This can be turned up by using apic=verbose for more* information and apic=debug for _lots_ of information.* apic_verbosity is defined in apic.c(APIC_VERBOSE, "..... mult: %u\n", mult)
969  Define the default level of output to be very little* This can be turned up by using apic=verbose for more* information and apic=debug for _lots_ of information.* apic_verbosity is defined in apic.c(APIC_VERBOSE, "..... calibration result: %u\n", lapic_timer_period)
972  If boot_cpu_has(Time Stamp Counter ) Then
973  Define the default level of output to be very little* This can be turned up by using apic=verbose for more* information and apic=debug for _lots_ of information.* apic_verbosity is defined in apic.c(APIC_VERBOSE, "..... CPU clock speed is %ld.%04ld MHz.\n", (deltatsc / In this functions we calibrate APIC bus clocks to the external timer) / (1000000 / HZ), (deltatsc / In this functions we calibrate APIC bus clocks to the external timer) % (1000000 / HZ))
979  Define the default level of output to be very little* This can be turned up by using apic=verbose for more* information and apic=debug for _lots_ of information.* apic_verbosity is defined in apic.c(APIC_VERBOSE, "..... host bus clock speed is %u.%04u MHz.\n", lapic_timer_period / (1000000 / HZ), lapic_timer_period % (1000000 / HZ))
987  If lapic_timer_period < 1000000 / HZ Then
988  The local_irq_*() APIs are equal to the raw_local_irq*()* if !TRACE_IRQFLAGS.()
989  pr_warn("APIC frequency too slow, disabling apic timer\n")
990  Return -1
993  features &= ~CLOCK_EVT_FEAT_DUMMY
1000  If Not pm_referenced && HPET replaces the PIT, when enabled. So we need to know, which of* the two timers is used Then
1001  Define the default level of output to be very little* This can be turned up by using apic=verbose for more* information and apic=debug for _lots_ of information.* apic_verbosity is defined in apic.c(APIC_VERBOSE, "... verify APIC timer\n")
1006  event_handler = Temporary interrupt handler and polled calibration function.
1007  lapic_timer_set_periodic(levt)
1008  lapic_cal_loops = -1
1011  The local_irq_*() APIs are equal to the raw_local_irq*()* if !TRACE_IRQFLAGS.()
1013  When lapic_cal_loops <= In this functions we calibrate APIC bus clocks to the external timer cycle
1014  cpu_relax()
1017  local_irq_disable()
1018  lapic_timer_shutdown(levt)
1021  deltaj = lapic_cal_j2 - lapic_cal_j1
1022  Define the default level of output to be very little* This can be turned up by using apic=verbose for more* information and apic=debug for _lots_ of information.* apic_verbosity is defined in apic.c(APIC_VERBOSE, "... jiffies delta = %lu\n", deltaj)
1025  If deltaj >= In this functions we calibrate APIC bus clocks to the external timer - 2 && deltaj <= In this functions we calibrate APIC bus clocks to the external timer + 2 Then Define the default level of output to be very little* This can be turned up by using apic=verbose for more* information and apic=debug for _lots_ of information.* apic_verbosity is defined in apic.c(APIC_VERBOSE, "... jiffies result ok\n")
1027  Else features |= CLOCK_EVT_FEAT_DUMMY
1030  The local_irq_*() APIs are equal to the raw_local_irq*()* if !TRACE_IRQFLAGS.()
1032  If features & CLOCK_EVT_FEAT_DUMMY Then
1033  pr_warn("APIC timer disabled due to verification failure\n")
1034  Return -1
1037  Return 0
Caller
NameDescribe
x86_init_noopSetup the boot APIC* Calibrate and verify the result.