Question
I need to hook a hardware interrupts as soon as possible, avoiding if possible any:
- Other interruptions to take advantage of the CPU before mine.
- The latency added by Linux kernel to schedule, stats, and propagate IRQs.
This question shows how to hook interrupts directly from the hardware interrupt, but according to this other question, it is specific to I64 and X86 architecture. For ARM, one single interrupt handler exists, and there is little information on how to hook this interrupt.
My question is:
How to hook ARM hardware interrupt directly under Linux?
Context
Working on an embedded Linux device based on ARM Cortex 7, I am trying to achieve hard real-time and low-latency response.
In that attempt, I made several changes that already improved significantly the jitter, latency and overall real-time performance:
- A Preempt-RT patch is applied to the Linux Kernel.
- The real-time software is integrated as an IRQ in a kernel module.
- I disabled any non-critical driver and Linux service.
- From the two cores, core 0 is isolated: it is dedicated to this IRQ only. (Actually, this is only partially done: some kernel threads related to IRQs are still running on core 0).
I checked that:
- The processor frequency is not adjusted, energy governors are disabled by the preempt-rt patch.
- Linux seems to have no way to increase the priority of IRQs
request_irq
seems the deepest (closest to the hardware) IRQ that Linux provides.
After, this, I have some 35us response time average, with <5us typical deviation. However I still registered a couple of >500us response time when testing the system over several hours with load.
A hard real-time below 100us would be acceptable, but those 500us are out of range.
About FIQ:
Thanks to @Artlessnoise for it comments:
FIQ is another approach to the hard-real time on ARM, and I am exploring this other alternative separately. FIQ provides a first-priority interruption, that can preempt a standard IRQ.
However, FIQ has some negative sides that make standard IRQ worth to explore:
- The Linux that I am using (OpenSt-linux) uses the FIQ for Trustzone (Optee) mode.
- FIQ uses GPLv2 license without Tovald note, making any driver using the Linux API to registers a FIQ GPLv2.
- FIQ uses special registers, this either enforce the use of Assembler, or compiler-specific code (e.g. GCC manages FIQ code).
For all those reasons, I am not discarding the option of FIQ, but I am still interested in achieving and see the performance of an IRQs hook.