arch/intel64: get TSC frequency only when not provided from Kconfig

on ACRN hypervisor obtaining frequency from CPUID seems to be broken,
so we have to specify this value from Kconfig.

If frequency autodetection is enabled but the returned data are
incorrect - crash early.

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
This commit is contained in:
p-szafonimateusz 2024-05-17 13:24:04 +02:00 committed by Alan Carvalho de Assis
parent 05842e726f
commit c5d1eaae72
2 changed files with 7 additions and 4 deletions

View File

@ -77,7 +77,8 @@ config ARCH_INTEL64_CORE_FREQ_KHZ
default 2000000
---help---
The CPU Core frequency (without Turbo boost). This is used
to set the TSC deadline timer frequency.
to set the TSC deadline timer frequency. If set to 0 we try to get
frequency from CPUID.
endif

View File

@ -72,7 +72,7 @@ extern unsigned long g_x86_64_timer_freq;
void x86_64_timer_calibrate_freq(void)
{
#ifdef CONFIG_ARCH_INTEL64_TSC_DEADLINE
# if CONFIG_ARCH_INTEL64_CORE_FREQ_KHZ == 0
unsigned long crystal_freq;
unsigned long numerator;
unsigned long denominator;
@ -84,13 +84,15 @@ void x86_64_timer_calibrate_freq(void)
if (numerator == 0 || denominator == 0 || crystal_freq == 0)
{
g_x86_64_timer_freq = CONFIG_ARCH_INTEL64_CORE_FREQ_KHZ * 1000L;
PANIC();
}
else
{
g_x86_64_timer_freq = crystal_freq / denominator * numerator;
}
# else
g_x86_64_timer_freq = CONFIG_ARCH_INTEL64_CORE_FREQ_KHZ * 1000L;
# endif
#elif defined(CONFIG_ARCH_INTEL64_TSC)
g_x86_64_timer_freq = CONFIG_ARCH_INTEL64_APIC_FREQ_KHZ * 1000L;
#endif