From 73cb4ab26e6e8bf9a993e6d0cd005ff80b7a6b15 Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Wed, 18 Sep 2024 09:52:02 +0200 Subject: [PATCH] core: delay: fix timeout expiration threshold Fix timeout threshold that should return once the time expires, not 1 tick after it has expired. This change makes udelay(0) to immediately return and not wait a generic timer counter increment. This change fixes an issue where a driver stops the counter feeding Arm generic timer counter and indirectly calls IO_READ32_POLL_TIMEOUT() with a delay of 0us. It that case, since counter never increments, the udelay(0) call in IO_READ32_POLL_TIMEOUT() never returns while we expect the macro to endlessly poll (as timeout would never be detected) until poll condition is met or system watchdog is triggered. Signed-off-by: Etienne Carriere --- core/include/kernel/delay.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/include/kernel/delay.h b/core/include/kernel/delay.h index 312d3072c38..289d2140f64 100644 --- a/core/include/kernel/delay.h +++ b/core/include/kernel/delay.h @@ -52,7 +52,7 @@ static inline uint64_t timeout_init_us(uint32_t us) static inline bool timeout_elapsed(uint64_t expire) { - return delay_cnt_read() > expire; + return delay_cnt_read() >= expire; } /*