Interrupts (Slideshow)

Interrupt Facts

  • Interrupt context is not scheduled

  • No sleeping API calls allowed

  • Not easily debugged

  • Not easy in general

  • No prioritization

But

  • Threaded interrupt handlers

  • … thanks to PREEMPT_RT slowly being integrated in mainline

Interrupt Service Routine

#include <linux/interrupt.h>

irqreturn_t irq_handler(int irq, void *cookie) { ... }
  • irq: the interrupt number that is active

  • cookie: opque pointer, given as cookie when IRQ is requested

  • Return value …

** irqreturn_t values**

IRQ_NONE

interrupt was not from this device or was not handled (shared interrupt?)

IRQ_HANDLED

interrupt was handled by this device

important! (Else line may remain active)

IRQ_WAKE_THREAD

handler requests to wake the handler thread (for threaded interrupts)

Requesting (and Releasing) Interrupts (1)

#include <linux/interrupt.h>

int request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *name, void *cookie);
const void* free_irq(unsigned int irq, void *cookie);
  • irq: the requested interrupt line

  • handler: interrupt handler to attach to irq

  • flags: a meaningful combination of

    IRQF_SHARED

    Multiple interrupts shared on same line

    IRQF_TRIGGER_RISING

    Edge triggered: rising

    IRQF_TRIGGER_FALLING

    Edge triggered: falling

    IRQF_TRIGGER_HIGH

    Level triggered: high

    IRQF_TRIGGER_LOW

    Level triggered: low

  • name: shows up in /proc/interrupts

  • cookie: echoed back into interrupt handler when called

Note

After successful call to request_irq() line is hot immediately

Documentation