kernel/timeout: Fix off-by-one in absolute timeouts

The computation was using the already-adjusted input value that
assumed relative timeouts and not the actual argument the user passed.
Absolute timeouts were consistently waking up one tick early.

Fixes #32499

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2021-02-19 13:07:46 -08:00 committed by Anas Nashif
parent 8a00e2c024
commit 252764a4ba

View file

@ -98,7 +98,7 @@ void z_add_timeout(struct _timeout *to, _timeout_func_t fn,
k_ticks_t ticks = timeout.ticks + 1;
if (IS_ENABLED(CONFIG_TIMEOUT_64BIT) && Z_TICK_ABS(ticks) >= 0) {
ticks = Z_TICK_ABS(ticks) - (curr_tick + elapsed());
ticks = Z_TICK_ABS(timeout.ticks) - (curr_tick + elapsed());
}
__ASSERT(!sys_dnode_is_linked(&to->node), "");