From 5ec3deac6b3bd8f8cc16730f2017a7316da816c9 Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Tue, 6 Feb 2024 22:52:06 -0800 Subject: libpayload: timer: Revert timer_hz() return type to 64-bits It seems that reducing the return type of timer_hz() to uint32_t in CB:78888 was a bad idea... some Intel platforms actually use their raw CPU clock for the timestamp counter which can be higher than 4GHz. This patch reverts it back to uint64_t. Also remove the redundant assertion in timer/generic.c since timer_us() itself already does that check. Cq-Depend: chromium:5274555 Change-Id: I471c7de7a28aec5bb965b23525ed579481ac8361 Signed-off-by: Julius Werner Reviewed-on: https://review.coreboot.org/c/coreboot/+/80320 Tested-by: build bot (Jenkins) Reviewed-by: Nico Huber Reviewed-by: Yidi Lin --- payloads/libpayload/drivers/timer/arm64_arch_timer.c | 2 +- payloads/libpayload/drivers/timer/generic.c | 4 +--- payloads/libpayload/drivers/timer/rdtsc.c | 5 ++--- 3 files changed, 4 insertions(+), 7 deletions(-) (limited to 'payloads/libpayload/drivers/timer') diff --git a/payloads/libpayload/drivers/timer/arm64_arch_timer.c b/payloads/libpayload/drivers/timer/arm64_arch_timer.c index b4d2b865ae..087d9e7565 100644 --- a/payloads/libpayload/drivers/timer/arm64_arch_timer.c +++ b/payloads/libpayload/drivers/timer/arm64_arch_timer.c @@ -32,7 +32,7 @@ #include #include -uint32_t timer_hz(void) +uint64_t timer_hz(void) { return raw_read_cntfrq_el0(); } diff --git a/payloads/libpayload/drivers/timer/generic.c b/payloads/libpayload/drivers/timer/generic.c index bd5674be8c..46bc291c13 100644 --- a/payloads/libpayload/drivers/timer/generic.c +++ b/payloads/libpayload/drivers/timer/generic.c @@ -33,10 +33,8 @@ #include #include -uint32_t timer_hz(void) +uint64_t timer_hz(void) { - /* libc/time.c currently requires all timers to be at least 1MHz. */ - assert(CONFIG_LP_TIMER_GENERIC_HZ >= 1000000); return CONFIG_LP_TIMER_GENERIC_HZ; } diff --git a/payloads/libpayload/drivers/timer/rdtsc.c b/payloads/libpayload/drivers/timer/rdtsc.c index 952bc0bb13..d5bf1d2057 100644 --- a/payloads/libpayload/drivers/timer/rdtsc.c +++ b/payloads/libpayload/drivers/timer/rdtsc.c @@ -35,10 +35,9 @@ #include #include -uint32_t timer_hz(void) +uint64_t timer_hz(void) { - assert(UINT32_MAX / 1000 >= lib_sysinfo.cpu_khz); - return lib_sysinfo.cpu_khz * 1000; + return (uint64_t)lib_sysinfo.cpu_khz * 1000; } uint64_t timer_raw_value(void) -- cgit v1.2.3