Skip to contentSkip to conversation

x86/tsc: Update tsc crystal_khz whitelist

PATCH Superseded Prarit Bhargava 3 participants 7 messages Sep 15, 2016 x86

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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.

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]>

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
#1 lore raw

PATCH 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.

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, 4 insertions(+), 3 deletions(-)
arch/x86/kernel/tsc.c +4 -3
index 78b9cb5a26af..2344758ba8a3 100644
@@ -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
#2 lore raw

PATCH 2/2 x86/tsc: Add additional Intel CPU models to crystal_khz whitelist

In reply to Prarit Bhargava

In 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.

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 +7 -0
index 2344758ba8a3..dfa70a8867dc 100644
@@ -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 = 24000;	/* 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
#3 lore raw

Re: [PATCH 2/2] x86/tsc: Add additional Intel CPU models to crystal_khz whitelist

arch/x86/kernel/tsc.c unsigned long native_calibrate_tsc(void) · line 697

Quoted 11 lines · Prarit Bhargava

+++ b/arch/x86/kernel/tsc.c

arch/x86/kernel/tsc.c +4 -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 = 24000;	/* 25.0 MHz */
					^^^  !=   ^^^^

did you mean to type: 25000 ?

Quoted 12 lines
arch/x86/kernel/tsc.c +3 -0
+			break;
 		case INTEL_FAM6_ATOM_GOLDMONT:
 			crystal_khz = 19200;	/* 19.2 MHz */
 			break;
+		default:
+			crystal_khz = 0;
 		}
 	}
 
Signature · 1 line
1.7.9.3
#4 lore raw

RE: [PATCH 2/2] x86/tsc: Add additional Intel CPU models to crystal_khz whitelist

In reply to Prarit Bhargava

arch/x86/kernel/tsc.c unsigned long native_calibrate_tsc(void) · line 697

Quoted 1 line
arch/x86/kernel/tsc.c +1 -0
+			crystal_khz = 24000;	/* 25.0 MHz */

I guess I prefer no comment over an incorrect comment.

#5 lore raw

Re: [PATCH 2/2] x86/tsc: Add additional Intel CPU models to crystal_khz whitelist

Quoted 6 lines · Len

arch/x86/kernel/tsc.c unsigned long native_calibrate_tsc(void) · line 697

Quoted 1 line
arch/x86/kernel/tsc.c +1 -0
+			crystal_khz = 24000;	/* 25.0 MHz */

I guess I prefer no comment over an incorrect comment.

From this I take it it should really have been 24 MHz and it could have

joined the existing case. I assumed (ha!) that since it had a special separate case the comment was correct.

#6 lore raw

Re: [PATCH 2/2] x86/tsc: Add additional Intel CPU models to crystal_khz whitelist

Quoted 9 lines · Peter Zijlstra
Quoted 4 lines · Len

arch/x86/kernel/tsc.c unsigned long native_calibrate_tsc(void) · line 697

Quoted 1 line
arch/x86/kernel/tsc.c +1 -0
+			crystal_khz = 24000;	/* 25.0 MHz */

I guess I prefer no comment over an incorrect comment.

From this I take it it should really have been 24 MHz and it could have joined the existing case. I assumed (ha!) that since it had a special separate case the comment was correct.

AFAICT, it should be 25000. Len -- can you explicitly confirm that? The turbostat code contains (tools/power/x86/turbostat/turbostat.c:3312)

                                case 0x55:      /* SKX */
                                        crystal_hz = 25000000;  /* 25.0 MHz */

P.

Quoted 1 line