Skip to content

Commit

Permalink
core: timeout_elapsed(): fix 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]>
Acked-by: Jens Wiklander <[email protected]>
Reviewed-by: Jerome Forissier <[email protected]>
  • Loading branch information
etienne-lms authored and jforissier committed Sep 19, 2024
1 parent 16b9b1e commit a757483
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 a757483

Please sign in to comment.