zephyr: make sure non-atomic 64-bit timer is consistent

The Zephyr timer implementation reads high and low 32 bits
in a non-atomic way. Add a loop to make sure the read is
consistent.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This commit is contained in:
Guennadi Liakhovetski 2021-02-01 15:13:38 +01:00 committed by Liam Girdwood
parent 9ac38d8828
commit 372d3873bd
1 changed files with 6 additions and 4 deletions

View File

@ -277,10 +277,12 @@ uint64_t platform_timer_get(struct timer *timer)
uint32_t high;
uint64_t time;
/* read low 32 bits */
low = shim_read(SHIM_EXT_TIMER_STAT);
/* TODO: check and see whether 32bit IRQ is pending for timer */
high = timer->hitime;
do {
/* TODO: check and see whether 32bit IRQ is pending for timer */
high = timer->hitime;
/* read low 32 bits */
low = shim_read(SHIM_EXT_TIMER_STAT);
} while (high != timer->hitime);
time = ((uint64_t)high << 32) | low;