public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] Add hardcoded crystal clock for KabyLake
@ 2022-10-18 19:01 Rishabh Agrawal
  2022-10-20 17:13 ` Peter Zijlstra
  0 siblings, 1 reply; 5+ messages in thread
From: Rishabh Agrawal @ 2022-10-18 19:01 UTC (permalink / raw)
  To: LKML, len.brown, drake, rafael.j.wysocki, mingo, tglx
  Cc: vaibhav.shankar, biernacki, zwisler, mattedavis, Rishabh Agrawal,
	Borislav Petkov, Dave Hansen, Feng Tang, Greg Kroah-Hartman,
	H. Peter Anvin, Peter Zijlstra, x86

Set KabyLake crystal clock manually since the TSC calibration is off
by 0.5%. All the tests that are based on the timer/clock will fail in
this case.

The HPET has been disabled by upstream due to PC10 issue causing the
3 hatch devices, dratini, jinlon, and kohaku to not calibrate the clock
precisely. These 3 devices are KabyLake devices. Intel team has verified
that all KBL devices have 24.0 MHz clock frequency, therefore this
change is valid.

Signed-off-by: Rishabh Agrawal <rishabhagr@chromium.org>
---

Changes in v2:
  - Adding Thomas Gleixner, Daniel Drake, Rafael Wysocki, Len brown and Ingo to review since you worked on this.

 arch/x86/kernel/tsc.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index cafacb2e58cc..63a06224fa48 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -644,10 +644,21 @@ unsigned long native_calibrate_tsc(void)
 	 * Denverton SoCs don't report crystal clock, and also don't support
 	 * CPUID.0x16 for the calculation below, so hardcode the 25MHz crystal
 	 * clock.
+	 *
+	 * Intel KabyLake devices' clocks are off by 0.5% when using the below
+	 * calculation, so hardcode 24.0 MHz crystal clock.
 	 */
-	if (crystal_khz == 0 &&
-			boot_cpu_data.x86_model == INTEL_FAM6_ATOM_GOLDMONT_D)
-		crystal_khz = 25000;
+	if (crystal_khz == 0) {
+		switch (boot_cpu_data.x86_model) {
+		case INTEL_FAM6_ATOM_GOLDMONT_D:
+			crystal_khz = 25000;
+			break;
+		case INTEL_FAM6_KABYLAKE_L:
+			crystal_khz = 24000;
+			break;
+		}
+
+	}
 
 	/*
 	 * TSC frequency reported directly by CPUID is a "hardware reported"
-- 
2.38.0.413.g74048e4d9e-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-12-21 22:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-18 19:01 [PATCH v2] Add hardcoded crystal clock for KabyLake Rishabh Agrawal
2022-10-20 17:13 ` Peter Zijlstra
2022-10-20 17:18   ` Dave Hansen
2022-11-14 22:58     ` Thomas Gleixner
2022-12-21 22:35       ` Christian A. Ehrhardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox