From 7c0f70b65b7c6ab0c09f87932615c65142542ed5 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 27 Aug 2024 19:44:26 -0600 Subject: [PATCH] x86: Avoid timer-clock overflow When the clock speed is above about 4GHz, e.g. on modern PC hardware, the timer overflows, resulting in a much lower frequency than expected. Deal with this by capping the clock speed. It would be possible to move to a 64-bit value for the clock, but that is a pain to deal with. A better approach might be to express the clock in MHz but that is left for later consideration. Signed-off-by: Simon Glass --- drivers/timer/tsc_timer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/timer/tsc_timer.c b/drivers/timer/tsc_timer.c index d11227cf44..2f2c2f27b7 100644 --- a/drivers/timer/tsc_timer.c +++ b/drivers/timer/tsc_timer.c @@ -442,6 +442,7 @@ static void tsc_timer_ensure_setup(bool early) return; done: + fast_calibrate = min(fast_calibrate, 4000UL); if (!gd->arch.clock_rate) gd->arch.clock_rate = fast_calibrate * 1000000; } -- 2.39.5