Re: Detection of interrupt by interrupt handler not originating from the device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rajendra Stalekar wrote:
Hi,

Wanted to know a scenario wherein an interrupt is detected by the interrupt handler whose device is not the originator. How is that possible ? We have a dev_id parameter to detect the device for any interrupt.


This would be the case with shared interrupts. Note that every shared interrupt handler will be invoked for each pending interrupt that occurs on the line until we return IRQ_HANDLED from one of the interrupt routines (and maybe clear the interrupt status in the device register - se below). See LDD3 chapter 10 section 3 for more detail.

When we write our own interrupt handler , let’s say the interrupt line is shared for that interrupt, yet we have the dev_id parameter for the interrupt, so how can the interrupt handler detect the interrupt not originating from the device. It will detect the interrupt only for the device associated with dev_id.

See LDD3 chapter 10 section 5. In general for shared interrupts you would need some kind of external indicator to know exactly which device interrupted. That will be eg. a status register in either the interrupt controller or device itself. Many times devices can report pending interrupts via single status bit that can be read from a register inside the device. After establishing (inside the interrupt handler) that we were indeed interrupted by the 'correct' device (eg. the interrupt bit is set) we handle the interrupt, otherwise ignore the interrupt and possibly let other interrupt handlers registered for the same IRQ number do the job. It is worth mentioning that some devices may need some kind of procedure to clear the interrupt in the device itself (setting/clearing the interrupt status bit) otherwise interrupt would be fired indefinitely.

When registering the interrupt handler some kind of private (and unique) data for dev_id *must* be specified. As LDD3 suggests the best candidate for this would be pointer to device data structure. To finally answer the question: I don't think it is possible for interrupt handler to work this out for himself if not assisted from the device itself - eg. by reading the device status register or similar. LDD3 is little vague on this subject, it says that free_irq is the main reason for use of unique dev_id, while each interrupt handler is on its own when recognizing the device which fired the interrupt. Since every interrupt handler receives its own dev_id when invoked, its impossible to know what other devices might be also hooked to the same IRQ line.

regards,
hinko

--
ČETRTA POT, d.o.o., Kranj
Planina 3
4000 Kranj
Slovenia, Europe
Tel. +386 (0) 4 280 66 03
E-mail: hinko.kocevar@xxxxxxxxxxxx
Http: www.cetrtapot.si


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux