Skip to content

Commit

Permalink
core: delay: fix timeout expiration threshold
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
etienne-lms committed Sep 18, 2024
1 parent 16b9b1e commit 73cb4ab
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/include/kernel/delay.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*
Expand Down

0 comments on commit 73cb4ab

Please sign in to comment.