On Sat, Sep 11, 2010 at 07:50:43PM +0200, fabio de francesco wrote: > Hi all, > > For exercise purposes I have coded a device driver that shares an IRQ line > with other devices. > > In the code from the book I am reading (Cooperstein's), the interrupt handler > returns IRQ_NONE. Close to that code there's the comment "We're just > observing". > > What I don't understand is why the author chose to return IRQ_NONE instead of > IRQ_HANDLED. Must I return IRQ_NONE because my driver isn't effectively > handling the device? May be in order to not prevent the real driver to handle > the interrupts on the shared line? Yes, if you have registered a handler on a shared IRQ, the first thing your handler must do is determine if it was your device which generated the interrupt. If it wasn't your device, you return IRQ_NONE. If you claim that you handled the interrupt by returning IRQ_HANDLED, but you really didn't do anything, there are situations where you will cause an interrupt storm and lock the system up tight (or at least one processor). Consider the following scenario: 1. You've attached an interrupt to device A via request_irq(). 2. Device A asserts the IRQ 3. You're handler is called 4. You don't quiesce the device, but you return IRQ_HANDLED 5. The core code sees that that you returned IRQ_HANDLED, so assumes the . device has unasserted the IRQ and unmasks the IRQ 6. But the device is still asserting the IRQ! 7. The IRQ core code jumps back to 3 8. ...lockup! Now, if you've attached yourself to a shared IRQ chain that contains a legitimate handler for device A, you _might_ be okay returning IRQ_HANDLED (because the core code will still continue down the chain and call the real handler, which _will_ quiesce the device). But don't do this. Especially if you register your registering your handler w/ IRQF_SAMPLE_RANDOM, as you'll likely compromise the entropy of the system. > > Sorry for my poor English... Thanks in advance. Your english is fine! -- -joshc -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ