Fix the calculation of 64bit timeout.

Before the 1st rollover, timer->hitimeout = 0, it will cause
platform_timer_64_handler() set timeout = 1.
So the time irq is forced to be fired at the beginning of rollover.
And the timeout of platform_timer_set() will be invalid and work
queue cannot be fired.

Just set the new hitimeout to timer->hitimeout.
timer->hitime will be added in the next rollover.
It is unnecessary to check timer->hitimout > 0.

Signed-off-by: Yan Wang <yan.wang@linux.intel.com>
This commit is contained in:
Yan Wang 2017-10-09 15:31:55 +08:00 committed by Liam Girdwood
parent c1917ddd94
commit 138fd825aa
1 changed files with 3 additions and 7 deletions

View File

@ -66,7 +66,7 @@ static void platform_timer_64_handler(void *arg)
}
/* get next timeout value */
if (timer->hitimeout > 0 && timer->hitimeout == timer->hitime) {
if (timer->hitimeout == timer->hitime) {
/* timeout is in this 32 bit period */
timeout = timer->lowtimeout;
} else {
@ -108,17 +108,13 @@ int platform_timer_set(struct timer *timer, uint64_t ticks)
flags = arch_interrupt_global_disable();
/* same hi 64 bit context as ticks ? */
if (hitimeout == timer->hitime) {
/* yes, then set the value for next timeout */
time = ticks;
timer->lowtimeout = 0;
timer->hitimeout = 0;
} else if (hitimeout < timer->hitime) {
if (hitimeout < timer->hitime) {
/* cant be in the past */
arch_interrupt_global_enable(flags);
return -EINVAL;
} else {
/* set for checking at next timeout */
time = ticks;
timer->hitimeout = hitimeout;
timer->lowtimeout = ticks;
}