summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2024-08-27 19:44:27 -0600
committerSimon Glass <sjg@chromium.org>2024-10-18 14:10:21 -0600
commitecf31113f17817f5ab9263937270255b6d05cdf9 (patch)
tree225926d81f56e26a2e59a7f27b3ab0e9c418bd8f
parent7c0f70b65b7c6ab0c09f87932615c65142542ed5 (diff)
x86: Sync up tsc_timer with Linux
Since we are using the code from Linux, update it to the newer version in v6.11 Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--drivers/timer/tsc_timer.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/timer/tsc_timer.c b/drivers/timer/tsc_timer.c
index 2f2c2f27b7f..dd16ab320b2 100644
--- a/drivers/timer/tsc_timer.c
+++ b/drivers/timer/tsc_timer.c
@@ -83,7 +83,7 @@ static unsigned long cpu_mhz_from_cpuid(void)
if (cpuid_eax(0) < 0x16)
return 0;
- return cpuid_eax(0x16);
+ return cpuid_eax(0x15);
}
/*
@@ -299,10 +299,19 @@ static unsigned long __maybe_unused quick_pit_calibrate(void)
if (!pit_expect_msb(0xff-i, &delta, &d2))
break;
+ delta -= tsc;
+
+ /*
+ * Extrapolate the error and fail fast if the error will
+ * never be below 500 ppm.
+ */
+ if (i == 1 &&
+ d1 + d2 >= (delta * MAX_QUICK_PIT_ITERATIONS) >> 11)
+ return 0;
+
/*
* Iterate until the error is less than 500 ppm
*/
- delta -= tsc;
if (d1+d2 >= delta >> 11)
continue;