Interrupt Handling in 2.6 Kernel

3 views
Skip to first unread message

Achindra Bhatnagar

unread,
Dec 6, 2007, 8:50:15 AM12/6/07
to Pappi-...@googlegroups.com, giGA...@googlegroups.com

I read an article today about massive rework on Interrupt handling in 2.6, here is abstract.


Interrupt handling for 2.6 kernel has been massively reworked but most parts of kernel remain unafected. There are two major updated
  • Interrupt handlers now return some value.
Earlier interrupt handlers used to return void, but now they tell the kernel if they can handle the interrupt or not.
For each interrupt generated by a device, kernel knows if it is spurious - if their is no interrupt handler registered for the IRQ it is spurious. But now drivers can also tell the kernel if the interrupts being generated by the device are spurious or not, i.e if that can handle it or not. Interrupt handlers now return
irqreturn_t. If the interrupt handler recognizes and handles an interrupt it must return IRQ_HANDLED. If it knows the interrupt is on a device that it don't manages it can simply return IRQ_NONE.
  • No global disabling of interrupts.
No more cli(), sti(), store_flags() and restore_flags(). It has long been discouraged to globally disable interrupts and now is not possible. Use spinlocks to protect any data structure that was being protected by a global interrupt disabling. However local interrupt disabling (all interrupts on a CPU) is still possible. local_irq_disable() or local_save_flags() for the purpose. disable_irq() to disable an interrupt globally is available.

Another interesting feature updated is synchronize_irq(). This function takes a single argument as interrupt number and spins untill no interrupt handler is running for that IRQ. If you disable that IRQ before calling the function, it is sure when it returns that no handler be running. It is not IRQ specific and cannot be used for a global check on all IRQs.

Also declarations of request_irq() and free_irq() have moved from linux/sched.h to linux/interrupt.h

As we know that bottom halves have been deprecated in 2.6, there is another way of doing bottom halves stuff than the tasklets. And this mechanism is Work Queues.

Work Queues are list of tasks to be performed with a per CPU worker thread (kernel thread). These worker threads run in process context and can thus sleep. Apart from queuing some work to be done, we can also delay queued-work, i.e work to execute after a predefined delay. You can wait on a flush call before you unload your driver, this will ensure that all work queued on the target work queue is complete. Also, a call to destroy workqueue will actually first call a flush.

For tasks that do not need their own workqueues can use the default work queue (called "events"). However there is a catch, a non GPL code can only use the events workqueue and not work on seperate workqueues.

Does this mean, GPL is not about freedom anymore?

.-.
Regards
Bhatnagar Achindra

Happy Hacking!

Reply all
Reply to author
Forward
0 new messages