x86/tsc: Update tsc crystal_khz whitelist
v2 cover x86/tsc: Update tsc crystal_khz whitelist
native_calibrate_tsc() contains a whitelist of models that have a known TSC frequency that differs from the CPU frequency. This patchset switches the code from using magic numbers to using the defines in asm/intel-family.h and adds new processors to the whitelist.
v2: peterz, fixed typo in patch 0002. There was some question if the value was supposed to be 25000 or 24000. Experimenting on an 0x55 processor shows that 25000 is correct.
Prarit Bhargava (2):
x86,tsc: Use cpu id defines from intel-family.h x86/tsc: Add additional Intel CPU models to crystal_khz whitelist
arch/x86/kernel/tsc.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
Signature · 1 line
1.7.9.3
PATCH v2 1/2 x86,tsc: Use cpu id defines from intel-family.h
asm/intel-family.h contains defines for cpu ids which should be used in the native_calibrate_tsc() function.
--- arch/x86/kernel/tsc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/x86/kernel/tsc.c +4 -3
@@ -23,6 +23,7 @@#include <asm/x86_init.h> #include <asm/geode.h> #include <asm/apic.h> +#include <asm/intel-family.h> unsigned int __read_mostly cpu_khz;/* TSC clocks / usec, not used here */ EXPORT_SYMBOL (cpu_khz);
@@ -686,11 +687,11 @@ unsigned long native_calibrate_tsc(void)if (crystal_khz ==0 ) {switch (boot_cpu_data.x86_model) { -case 0x4E :/* SKL */ -case 0x5E :/* SKL */ +case INTEL_FAM6_SKYLAKE_MOBILE : +case INTEL_FAM6_SKYLAKE_DESKTOP : crystal_khz =24000 ;/* 24.0 MHz */ break ; -case 0x5C :/* BXT */ +case INTEL_FAM6_ATOM_GOLDMONT : crystal_khz =19200 ;/* 19.2 MHz */ break ; }
Signature · 1 line
1.7.9.3
tip-bot for Prarit Bhargava
merge bot[tip:x86/timers] x86/tsc: Use cpu id defines instead of hex constants
x86/tsc: Use cpu id defines instead of hex constants
Commit-ID: 655e52d2b62458032fc67ff7daaa664af6f36fb5 Gitweb: http://git.kernel.org/tip/655e52d2b62458032fc67ff7daaa664af6f36fb5 Author: Prarit Bhargava <[email protected]> AuthorDate: Mon, 19 Sep 2016 08:51:40 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 20 Sep 2016 01:00:32 +0200
x86/tsc: Use cpu id defines instead of hex constants
asm/intel-family.h contains defines for cpu ids which should be used instead of hex constants. Convert the switch case in native_calibrate_tsc() to use the defines before adding more cpu models.
[ tglx: Massaged changelog ]
--- arch/x86/kernel/tsc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/x86/kernel/tsc.c +4 -3
@@ -23,6 +23,7 @@#include <asm/x86_init.h> #include <asm/geode.h> #include <asm/apic.h> +#include <asm/intel-family.h> unsigned int __read_mostly cpu_khz;/* TSC clocks / usec, not used here */ EXPORT_SYMBOL (cpu_khz);
@@ -686,11 +687,11 @@ unsigned long native_calibrate_tsc(void)if (crystal_khz ==0 ) {switch (boot_cpu_data.x86_model) { -case 0x4E :/* SKL */ -case 0x5E :/* SKL */ +case INTEL_FAM6_SKYLAKE_MOBILE : +case INTEL_FAM6_SKYLAKE_DESKTOP : crystal_khz =24000 ;/* 24.0 MHz */ break ; -case 0x5C :/* BXT */ +case INTEL_FAM6_ATOM_GOLDMONT : crystal_khz =19200 ;/* 19.2 MHz */ break ; }
PATCH v2 2/2 x86/tsc: Add additional Intel CPU models to crystal_khz whitelist
In reply to Prarit BhargavaIn commit aa297292d708 ("x86/tsc: Enumerate SKL cpu_khz and tsc_khz via CPUID"), the kernel added support for Intel processors which had a different CPU base-frequency and TSC frequency.
The turbostat utility has been updated with KBL and SKX processors, and they should also be added to the crystal_khz white list.
For example, on INTEL_FAM6_KABYLAKE_MOBILE native_calibrate_tsc() returns 0 MHz for tsc_khz and after this patch native_calibrate_tsc() returns 1608 MHz.
v2: peterz, fix typo for SKX should be 25000
--- arch/x86/kernel/tsc.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/x86/kernel/tsc.c +7 -0
@@ -689,11 +689,18 @@ unsigned long native_calibrate_tsc(void)switch (boot_cpu_data.x86_model) {case INTEL_FAM6_SKYLAKE_MOBILE :case INTEL_FAM6_SKYLAKE_DESKTOP : +case INTEL_FAM6_KABYLAKE_MOBILE : +case INTEL_FAM6_KABYLAKE_DESKTOP : crystal_khz =24000 ;/* 24.0 MHz */ break ; +case INTEL_FAM6_SKYLAKE_X : + crystal_khz =25000 ;/* 25.0 MHz */ +break ;case INTEL_FAM6_ATOM_GOLDMONT : crystal_khz =19200 ;/* 19.2 MHz */ break ; +default : + crystal_khz =0 ; } }
Signature · 1 line
1.7.9.3
tip-bot for Prarit Bhargava
merge bot[tip:x86/timers] x86/tsc: Add additional Intel CPU models to the crystal quirk list
x86/tsc: Add additional Intel CPU models to the crystal quirk list
Commit-ID: 6baf3d61821f5b38f27b4e9f044ad4d1e8f3d14f Gitweb: http://git.kernel.org/tip/6baf3d61821f5b38f27b4e9f044ad4d1e8f3d14f Author: Prarit Bhargava <[email protected]> AuthorDate: Mon, 19 Sep 2016 08:51:41 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 20 Sep 2016 01:00:32 +0200
x86/tsc: Add additional Intel CPU models to the crystal quirk list
commit aa297292d708 ("x86/tsc: Enumerate SKL cpu_khz and tsc_khz via CPUID") added code to retrieve the crystal and TSC frequency from CPUID leaves. If the crystal freqency is enumerated as 0,the resulting TSC frequency is 0 as well. For CPUs with a known fixed crystal frequency a quirk list is available to set the frequency,
Kabylake and SkylakeX CPUs are missing in the list of CPUs which need this quirk. Add them so the TSC frequency can be calculated correctly.
[ tglx: Removed the silly default case as the switch() is only invoked when
cpu_khz is 0. Massaged changelog. ]
--- arch/x86/kernel/tsc.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/x86/kernel/tsc.c +5 -0
@@ -689,8 +689,13 @@ unsigned long native_calibrate_tsc(void)switch (boot_cpu_data.x86_model) {case INTEL_FAM6_SKYLAKE_MOBILE :case INTEL_FAM6_SKYLAKE_DESKTOP : +case INTEL_FAM6_KABYLAKE_MOBILE : +case INTEL_FAM6_KABYLAKE_DESKTOP : crystal_khz =24000 ;/* 24.0 MHz */ break ; +case INTEL_FAM6_SKYLAKE_X : + crystal_khz =25000 ;/* 25.0 MHz */ +break ;case INTEL_FAM6_ATOM_GOLDMONT : crystal_khz =19200 ;/* 19.2 MHz */ break ;
Re: [PATCH 2/2 v2] x86/tsc: Add additional Intel CPU models to crystal_khz whitelist
In reply to Prarit BhargavaQuoted 37 lines · Prarit Bhargava
In commit
aa297292d708("x86/tsc: Enumerate SKLcpu_khzandtsc_khzvia CPUID"), the kernel added support for Intel processors which had a different CPU base-frequency and TSC frequency.The turbostat utility has been updated with KBL and SKX processors, and they should also be added to the
crystal_khzwhite list.For example, on
INTEL_FAM6_KABYLAKE_MOBILEnative_calibrate_tsc()returns 0 MHz fortsc_khzand after this patchnative_calibrate_tsc()returns 1608 MHz.v2: peterz, fix typo for SKX should be 25000
Signed-off-by Prarit Bhargava <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc "H. Peter Anvin" <[email protected]>Cc Rafael Aquini <[email protected]>Cc "Peter Zijlstra (Intel)" <[email protected]>Cc Andy Lutomirski <[email protected]>Cc Len Brown <[email protected]>--- arch/x86/kernel/tsc.c | 7 +++++++ 1 file changed, 7 insertions(+)arch/x86/kernel/tsc.c +2
-0@@ -689,11 +689,18 @@ unsigned long native_calibrate_tsc(void)switch (boot_cpu_data.x86_model) {case INTEL_FAM6_SKYLAKE_MOBILE :case INTEL_FAM6_SKYLAKE_DESKTOP : +case INTEL_FAM6_KABYLAKE_MOBILE : +case INTEL_FAM6_KABYLAKE_DESKTOP : crystal_khz =24000 ;/* 24.0 MHz */
arch/x86/kernel/tsc.c unsigned long native_calibrate_tsc(void) · line 704
Quoted 10 lines
arch/x86/kernel/tsc.c +5
-0break ; +case INTEL_FAM6_SKYLAKE_X : + crystal_khz =25000 ;/* 25.0 MHz */ +break ;case INTEL_FAM6_ATOM_GOLDMONT : crystal_khz =19200 ;/* 19.2 MHz */ break ; +default : + crystal_khz =0 ; }
Correct.