1
votes

Basic question about linux interrupt handling

In my driver i disable the interrupt line of a peripheral and do some processing, during this time peripheral is sending interrupt. when i enable the interrupt line i received the pending interrupt which happened during that time.

is this correct understanding?

If yes how can i discard those interrupt which came during the interrupt disable period.

I can implement some work around using some delay, looking for linux API or clean way to do this.

Before enabling the interrupt we can set desc = irq_to_desc(client->irq); desc->istate &= ~IRQS_PENDING; and enable the interrupt line it will clear all the pending interrupt, but the code says we should never modify these variable.

Thank you

1
And I don't think ignoring it is ever reasonable thing to do. You disable the line, read the event from the device and enable the line again. If an interrupt arrives while the line is disabled, you may have seen the event that triggered it, but as likely you may have not. So you shouldn't just ignore it; you have to check whether there are any unprocessed events again. - Jan Hudec
If we check __enable_irq function, it calls check_irq_resend(desc, irq); which will resend any pending interrupt. - shunty
Well, yes, because if the IRQ happened while it was disabled, it still has to be handled. If it wasn't, you could miss the event that caused it. - Jan Hudec

1 Answers

1
votes

May be I did not understood but I think what you must do is:

  • disable interupt on the device directly and not using kernel interrupt handling routines

  • the poll your device, fetching all event. may be you should do this in a threaded interrupt handler

  • when finished re-enable interrupts on the device