arch: arm: timer: mask interrupt in ISR

As timer interrupt is level triggered, we need to mask it before leaving
ISR or it will be delivered again.

Also, Xen automatically masks timer interrupt when it injects IRQ to
a guest, so we need to unmask it again, when setting new timeout.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
This commit is contained in:
Volodymyr Babchuk 2020-11-19 22:48:46 +02:00 committed by Anas Nashif
commit 35efb15637
2 changed files with 26 additions and 2 deletions

View file

@ -36,6 +36,9 @@ static void arm_arch_timer_compare_isr(const void *arg)
next_cycle += CYC_PER_TICK;
}
arm_arch_timer_set_compare(next_cycle);
arm_arch_timer_set_irq_mask(false);
} else {
arm_arch_timer_set_irq_mask(true);
}
k_spin_unlock(&lock, key);
@ -52,6 +55,7 @@ int z_clock_driver_init(const struct device *device)
arm_arch_timer_set_compare(arm_arch_timer_count() + CYC_PER_TICK);
arm_arch_timer_enable(true);
irq_enable(ARM_ARCH_TIMER_IRQ);
arm_arch_timer_set_irq_mask(false);
return 0;
}
@ -83,6 +87,7 @@ void z_clock_set_timeout(int32_t ticks, bool idle)
}
arm_arch_timer_set_compare(req_cycle + last_cycle);
arm_arch_timer_set_irq_mask(false);
k_spin_unlock(&lock, key);
#endif