The interrupt handler routine is your typical C code, with some caveats. A few key points regarding the design and implementation of your hardware interrupt handler are as follows:
- The handler runs in an interrupt context, so do not block: First and foremost, this code always runs in an interrupt context; that is, an atomic context. On a preemptible kernel, preemption is disabled, so there are some limitations regarding what it can and cannot do. In particular, it cannot do anything that directly or indirectly invokes the scheduler (schedule())!
In effect, you cannot do the following:- Transfer data to and from kernel to user space as it might cause a page fault, which isn't allowed in an atomic context.
- Use the GFP_KERNEL flag in memory allocation. You must use the GFP_ATOMIC flag so that the allocation is non-blocking – it either succeeds or fails immediately.
- Invoke any API that's blocking (that,...