drivers/timer/hpet: Extend qemu workaround
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: Andy Ross <c70f9a6bf6ee0cd69c8af4ce5e6b131945769315@intel.com>

nashif/zephyr,nashif/zephyr,galak/zephyr,zephyrproject-rtos/zephyr,Vudentz/zephyr,finikorg/zephyr,zephyrproject-rtos/zephyr,finikorg/zephyr,Vudentz/zephyr,finikorg/zephyr,Vudentz/zephyr,Vudentz/zephyr,galak/zephyr,finikorg/zephyr,Vudentz/zephyr,galak/zephyr,finikorg/zephyr,zephyrproject-rtos/zephyr,nashif/zephyr,galak/zephyr,nashif/zephyr,zephyrproject-rtos/zephyr,nashif/zephyr,Vudentz/zephyr,galak/zephyr,zephyrproject-rtos/zephyr