Skip to content

Commit

Permalink
linux-gen: timer: don't start posix timer with inline timers
Browse files Browse the repository at this point in the history
A wrong global variable (odp_global_rw->inline_timers) was used
to check if posix timers are used or not. That variable controls
if timers need to be polled in inline mode. The correct variable
is to check posix vs inline mode is
timer_global->use_inline_timers.

Signed-off-by: Petri Savolainen <[email protected]>
Reviewed-by: Matias Elo <[email protected]>
  • Loading branch information
psavol authored and MatiasElo committed Jan 17, 2025
1 parent 9cc4c60 commit 78d93b5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions platform/linux-generic/odp_timer.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2013-2018 Linaro Limited
* Copyright (c) 2019-2023 Nokia
* Copyright (c) 2019-2025 Nokia
*/

/**
Expand Down Expand Up @@ -354,7 +354,7 @@ static void odp_timer_pool_del(timer_pool_t *tp)

odp_spinlock_lock(&tp->lock);

if (!odp_global_rw->inline_timers)
if (!timer_global->use_inline_timers)
posix_timer_stop(tp);

if (tp->num_alloc != 0) {
Expand Down Expand Up @@ -1283,8 +1283,9 @@ static odp_timer_pool_t timer_pool_new(const char *name, const odp_timer_pool_pa
timer_global->timer_pool[tp_idx] = tp;
timer_global->tp_shm[tp_idx] = shm;

if (timer_global->num_timer_pools == 1)
odp_global_rw->inline_timers = timer_global->use_inline_timers;
/* Enable inline timer polling */
if (timer_global->use_inline_timers)
odp_global_rw->inline_timers = true;

/* Increase poll rate to match the highest resolution */
if (timer_global->poll_interval_nsec > nsec_per_scan) {
Expand All @@ -1299,7 +1300,7 @@ static odp_timer_pool_t timer_pool_new(const char *name, const odp_timer_pool_pa

odp_ticketlock_unlock(&timer_global->lock);

if (!odp_global_rw->inline_timers)
if (!timer_global->use_inline_timers)
posix_timer_start(tp);

return timer_pool_to_hdl(tp);
Expand Down Expand Up @@ -2092,7 +2093,7 @@ int _odp_timer_term_global(void)
rc = -1;

/* Prevent crash from timer thread */
if (!odp_global_rw->inline_timers) {
if (!timer_global->use_inline_timers) {
timer_pool_t *tp = timer_global->timer_pool[i];

if (tp != NULL)
Expand Down

0 comments on commit 78d93b5

Please sign in to comment.