According to https://developer.arm.com/documentation/102379/0101/The-processor-timers?lang=en
"
The interrupts generated by the timer behave in a level-sensitive manner. This means that, once the timer firing condition is reached, the timer will continue to signal an interrupt until one of the following situations occurs:
IMASK
ENABLE
TVAL
CVAL
When writing an interrupt handler for the timers, it is important that software clears the interrupt before deactivating the interrupt in the GIC. Otherwise the GIC will re-signal the same interrupt again."Does it mean we need a synchronization barrier (e.g. isb()) between two points:P1. TVAL gets updated. The firing confition is no longer met.
-> ISB()
P2. ICC_EOIR, ICC_DIROr ISB() is not enough and we need something else there?Thanks in advance
That's an interesting question!
There is an extra thing to consider - latency. The ISB can synchronise the change to the register, which (in this case) causes the timer's interrupt signal to be de-asserted. There will be a finite delay between the CPU de-asserting the signal, the de-assertion being observed by the GIC, and the GIC update the Pending state. You can check whether the GIC Redistributor (assuming GICv3?) has seen the change by reading back GICR_ISPENDR0.
What if you execute ICC_DIR before the de-assert propagates?
The sequence we're expecting is:
Instead we'd get:
There's a small chance that the GIC could "re-signal" the interrupt between the last two steps. But I think it very unlikely. The reason is for this situation to happen the deactivate (due to the write to ICC_DIR) has to propagate to the GIC faster than the change in the timer interrupt signal. The timer interrupt signal is a wire. The deactivate goes over a command bus using GIC Stream Protocol.
So if you care, then software can poll the GICx_ISPENDR<n> register. If you don't poll that register, you run a small chance of getting a spurious interrupt, which typically software can cope with.
Thanks for the explanation :)without ISB, Is it possible for an implementation to re-order TVAL after the ICC_EOIR/DIR? in that case would be much more likely to get a spurious IRQ?
The ISB ensures that the effects of the write to TVAL is visible to the ICC_EOIR/ICC_DIR. So yes, without you increase the chance of the timer interrupt signal still being asserted to the GIC when the Deactivate is sent if you remove the ISB.