From e1fd2311482c47bbab12c8555f2e04c891354a45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Chru=C5=9Bci=C5=84ski?= Date: Wed, 22 May 2024 07:39:21 +0200 Subject: [PATCH] [nrf fromtree] drivers: timer: nrf_grtc_timer: Fix for random hangs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit d599e2b6705eb removed early return from sys_clock_timeout_handler if current counter value is less than cc_val. It seems that this return is needed as after the removal some stress tests which were using system timers heavily started to hang. Signed-off-by: Krzysztof Chruściński (cherry picked from commit af3c8b973ede41f34bef107a71c3bc9de676b20c) (cherry picked from commit a56fee6870e152b71a7baf5b85bfa0b9746286a0) --- drivers/timer/nrf_grtc_timer.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/timer/nrf_grtc_timer.c b/drivers/timer/nrf_grtc_timer.c index a8b29b9dcc7..c257677edef 100644 --- a/drivers/timer/nrf_grtc_timer.c +++ b/drivers/timer/nrf_grtc_timer.c @@ -140,6 +140,11 @@ static void sys_clock_timeout_handler(int32_t id, uint64_t cc_val, void *p_conte ARG_UNUSED(id); ARG_UNUSED(p_context); uint64_t dticks; + uint64_t now = counter(); + + if (unlikely(now < cc_val)) { + return; + } dticks = counter_sub(cc_val, last_count) / CYC_PER_TICK;