Skip to content

Instantly share code, notes, and snippets.

@cwshu
Last active October 22, 2017 10:30
Show Gist options
  • Save cwshu/e4358c1ba6dda64e8f41a74bf7689ab1 to your computer and use it in GitHub Desktop.
Save cwshu/e4358c1ba6dda64e8f41a74bf7689ab1 to your computer and use it in GitHub Desktop.
// Linux interrupt handler
// request_irq()
// Linux 4.9
// setup handler to irqaction
- request_threaded_irq()
- source: include/linux/interrupt.h, kernel/irq/manage.c
- irqaction is a chain(queue?) in irq_desc
- if IRQF_SHARED isn't set, there is only one irqaction in the chain.
// details
request_irq()
- request_threaded_irq(): action->handler = handler
- __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
irqaction** old_ptr = &desc->action;
// set old_ptr to end of irqaction chain (action->next)
*old_ptr = new;
irq_pm_install_action(desc, new); => desc->nr_actions++:
// interrupt handling by irq_desc's irqaction's handler
- handle_simple_irq()
- call desc->action->handler()
- alternatives: handle_level_irq(), handle_edge_irq(), handle_fasteoi_irq(), handle_edge_eoi_irq()
- source: kernel/irq/chip.c, kernel/irq/handle.c
// details
void handle_simple_irq(struct irq_desc *desc)
=> irqreturn_t handle_irq_event(struct irq_desc *desc)
=> irqreturn_t handle_irq_event_percpu(struct irq_desc *desc)
=> irqreturn_t __handle_irq_event_percpu(struct irq_desc *desc, unsigned int *flags)
=> action->handler(irq, action->dev_id);
// misc
// 1. irq thread: irqaction->{thread, thread_fn}, kthread_create() at setup_irq_thread()
// 2. irq domain remapping: kernel/irq/irqdomain.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment