Skip to content

Commit

Permalink
linux-gen: timer: zero timer pool memory on reserve
Browse files Browse the repository at this point in the history
Fixes timer thread failing due to uninitialized variables.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
  • Loading branch information
MatiasElo authored and muvarov committed Nov 23, 2018
1 parent 406dc69 commit 02b60f6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions platform/linux-generic/odp_timer.c
Expand Up @@ -270,6 +270,7 @@ static odp_timer_pool_t timer_pool_new(const char *name,
{
uint32_t i, tp_idx;
size_t sz0, sz1, sz2;
uint64_t tp_size;
uint32_t flags = ODP_SHM_SW_ONLY;

if (odp_global_ro.shm_single_va)
Expand Down Expand Up @@ -299,12 +300,17 @@ static odp_timer_pool_t timer_pool_new(const char *name,
sz1 = ROUNDUP_CACHE_LINE(sizeof(tick_buf_t) * param->num_timers);
sz2 = ROUNDUP_CACHE_LINE(sizeof(_odp_timer_t) *
param->num_timers);
odp_shm_t shm = odp_shm_reserve(name, sz0 + sz1 + sz2,
ODP_CACHE_LINE_SIZE, flags);
tp_size = sz0 + sz1 + sz2;

odp_shm_t shm = odp_shm_reserve(name, tp_size, ODP_CACHE_LINE_SIZE,
flags);
if (odp_unlikely(shm == ODP_SHM_INVALID))
ODP_ABORT("%s: timer pool shm-alloc(%zuKB) failed\n",
name, (sz0 + sz1 + sz2) / 1024);
timer_pool_t *tp = (timer_pool_t *)odp_shm_addr(shm);

memset(tp, 0, tp_size);

tp->prev_scan = odp_time_global();
tp->time_per_tick = odp_time_global_from_ns(param->res_ns);
odp_atomic_init_u64(&tp->cur_tick, 0);
Expand Down

0 comments on commit 02b60f6

Please sign in to comment.