[linux-yocto] [PATCH 2/2] x86 tsc: enumerate BXT tsc_khz via CPUID
From: Len Brown Hard code the BXT crystal clock (aka ART - Always Running Timer) to 19.200 MHz, and use CPUID leaf 0x15 to determine the BXT TSC frequency. Use tsc_khz to sanity check BXT cpu_khz, which can be erroneous in some configurations. Signed-off-by: Bin Gao [lenb: simplified] Signed-off-by: Len Brown (cherry picked from commit dad7a9a9376716ffdf33aa719981a43cefa19ff4) Signed-off-by: Saul Wold --- arch/x86/kernel/tsc.c | 16 +++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 0123365..dd85b3c 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -688,7 +688,11 @@ unsigned long native_calibrate_tsc(void) switch (boot_cpu_data.x86_model) { case 0x4E: /* SKL */ case 0x5E: /* SKL */ - crystal_khz = 24000;/* 24 MHz */ + crystal_khz = 24000;/* 24.0 MHz */ + break; + case 0x5C: /* BXT */ + crystal_khz = 19200;/* 19.2 MHz */ + break; } } @@ -896,6 +900,8 @@ int recalibrate_cpu_khz(void) tsc_khz = x86_platform.calibrate_tsc(); if (tsc_khz == 0) tsc_khz = cpu_khz; + else if (abs(cpu_khz - tsc_khz) * 10 > tsc_khz) + cpu_khz = tsc_khz; cpu_data(0).loops_per_jiffy = cpufreq_scale(cpu_data(0).loops_per_jiffy, cpu_khz_old, cpu_khz); @@ -1256,8 +1262,16 @@ void __init tsc_init(void) cpu_khz = x86_platform.calibrate_cpu(); tsc_khz = x86_platform.calibrate_tsc(); + + /* +* Trust non-zero tsc_khz as authorative, +* and use it to sanity check cpu_khz, +* which will be off if system timer is off. +*/ if (tsc_khz == 0) tsc_khz = cpu_khz; + else if (abs(cpu_khz - tsc_khz) * 10 > tsc_khz) + cpu_khz = tsc_khz; if (!tsc_khz) { mark_tsc_unstable("could not calculate TSC khz"); -- 2.5.5 -- ___ linux-yocto mailing list linux-yocto@yoctoproject.org https://lists.yoctoproject.org/listinfo/linux-yocto
[linux-yocto] [PATCH 2/2] x86 tsc: enumerate BXT tsc_khz via CPUID
From: Bin Gao Hard code the BXT crystal clock (aka ART - Always Running Timer) to 19.200 MHz, and use CPUID leaf 0x15 to determine the BXT TSC frequency. Use tsc_khz to sanity check BXT cpu_khz, which can be erroneous in some configurations. Signed-off-by: Bin Gao [lenb: simplified] Signed-off-by: Len Brown Signed-off-by: Yong, Jonathan --- arch/x86/kernel/tsc.c | 18 +- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 75df3c0..5df7ae6 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -684,7 +684,11 @@ unsigned long native_calibrate_tsc(void) switch (boot_cpu_data.x86_model) { case 0x4E: /* SKL */ case 0x5E: /* SKL */ - crystal_khz = 24000;/* 24 MHz */ + crystal_khz = 24000;/* 24.0 MHz */ + break; + case 0x5C: /* BXT */ + crystal_khz = 19200;/* 19.2 MHz */ + break; } } @@ -882,8 +886,12 @@ int recalibrate_cpu_khz(void) if (cpu_has_tsc) { cpu_khz = x86_platform.calibrate_cpu(); tsc_khz = x86_platform.calibrate_tsc(); + if (tsc_khz == 0) tsc_khz = cpu_khz; + else if (abs(cpu_khz - tsc_khz) * 10 > tsc_khz) + cpu_khz = tsc_khz; + cpu_data(0).loops_per_jiffy = cpufreq_scale(cpu_data(0).loops_per_jiffy, cpu_khz_old, cpu_khz); @@ -1298,8 +1306,16 @@ void __init tsc_init(void) cpu_khz = x86_platform.calibrate_cpu(); tsc_khz = x86_platform.calibrate_tsc(); + + /* +* Trust non-zero tsc_khz as authorative, +* and use it to sanity check cpu_khz, +* which will be off if system timer is off. +*/ if (tsc_khz == 0) tsc_khz = cpu_khz; + else if (abs(cpu_khz - tsc_khz) * 10 > tsc_khz) + cpu_khz = tsc_khz; if (!tsc_khz) { mark_tsc_unstable("could not calculate TSC khz"); -- 2.7.3 -- ___ linux-yocto mailing list linux-yocto@yoctoproject.org https://lists.yoctoproject.org/listinfo/linux-yocto