rvanspaa wrote:Indeed, which leads me to ask if the try-finally is really needed? Also, is spinlock needed for a single CPU machine like the RPi?
The try/finally is really just part of our standard procedure template to ensure that the spinlock is released in the event of an early exit or error condition. Since there is no early exit path in the BCM2708GPIOInterruptHandler and any sort of exception inside an interrupt handler will be fatal anyway then the try/finally can safely be removed.
Technically speaking the spinlock is also probably optional in the case of the PiA/B/Zero because the only thing that will ever call the interrupt handler is an interrupt and further interrupts cannot occur (due to limitations in the interrupt controller of the Pi) until this function returns.
In a multi CPU environment such as the Pi2/3/4 then the spinlock is mandatory to prevent data corruption of the structures used to store the GPIO event state etc.
We might look at removing these items from the BCM2708GPIOInterruptHandler just to squeeze out that little bit of extra performance.