Skip to content
Commit 4ae44dd7 authored by Andy Ross's avatar Andy Ross Committed by Anas Nashif
Browse files

drivers/timer/hpet: Extend qemu workaround



Qemu when running more than one processor has a known synchronization
bug where counter values read from the HPET (notionally a single
global device) can be seen going "backwards" when read from different
CPUs.

There was a pre-existing workaround in the ISR that knew about this,
but the problem can crop up anywhere the counter value is used.  In
particular I caught it aliasing with the "max_ticks" computation in
z_clock_set_timeout(), where it would cause a rollover and the
resulting negative comparator value would result in no end of
hilarity.

Wrap all access to the counter register with a counter() inline that
(when the workaround is enabled) forces the result to be monotonic by
clamping it to a minimum of one more than the previously read value.

Signed-off-by: default avatarAndy Ross <andrew.j.ross@intel.com>
parent 419f3704
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment