Trigger Kernel Interrupt Handler: How? - linux-kernel

I am trying to understand Asynchronous Interrupt handling in kernel, ofcourse through the legendary Understanding the Linux Kernel.
In this process how and who will trigger Kernel Interrupt Handler?
I would like some one to help me correcting this and to clarify my question on
1)How and Who trigger Kernel Interrupt Handler?
2)How to define new or change existing hardware interrupt handlers?
Thank you in Advance!

This picture from Robert Love's "Linux Kernel Development" pretty well describes path of interrupt. Processor interrupts the kernel in the predefined enty point do_IRQ(). If there is corresponding interrupt handler, it will get executed.
To handle interrupt, you should register your interrupt handler with request_irq().

Related

KMDF: Handling IRQ

We need to handle IRQ in KMDF driver
I've registered EVT_WDF_DEVICE_RESOURCE_REQUIREMENTS_QUERY callback function but system does not call it.
EVT_WDF_DEVICE_PREPARE_HARDWARE is called without any resources allocated.
Attempt to call WdfInterruptCreate() here results STATUS_INVALID_DEVICE_STATE
What is the right way to get free IRQ number from system and attach an interrupt handler?
Upd:
After we have successfully created WDFINTERRUPT object in our AddDevice handler system still does not ask us about resources (EVT_WDF_DEVICE_RESOURCE_REQUIREMENTS_QUERY)
After discussion on social.msdn.microsoft.com we've found only one solution: use another OS

Interrupt handler triggered when free_irq is called

My problem is:
Interrupt handler get triggered when free_irq is called. I noticed in kernel messages that handler is invoked but since our device hasn't requested interrupt it prompted that no interrupt has received.
Is it expected behavior ? Can anybody please help ?
When you are registering a handler for a (possibly) shared interrupt (with IRQF_SHARED), the interrupt can be triggered by other devices over which your driver has no control, so your driver must be prepared to receive an interrupt at any time.
To help with debugging drivers, the kernel will (when CONFIG_DEBUG_SHIRQ is set) fake some interrupts to check that your driver works correctly.
[source code]
If I understood your post right - you must turn off issuing interrupts in your hardware before you call free_irq() then you won't receive interrupts while free_irq().

Hardware IO Access from Interrupt Handler with Windows XP 32 bit

I have a Windows XP application that is using a driver called TVicHW32 which allows me to create an interrupt handler for OS interrupts. Currently I am using a custom ISA card in an industrial chassis with IRQ 5
The interrupt handler code is working and I can see a variable being incremented so the code that sets up and handles the interrupt is working.
The issue I have is that an IO access call fails to generate any IO activity on the ISA bus. I have an address at 0x308 that is used to trigger a start pulse on the ISA bus interface board.
If I trigger this pulse from the main code, for example, from a timer, the pulse is detected on the ISA bus and the card responds.
If I call the exact same function call to access that IO address from within the interrupt handler, nothing appears on the ISA bus. A logic analyser confirms this.
I have emailed the supplier of the driver but that can't help so I was wondering if anyone here has come across this situation and can offer a solution. This is critical to getting this project working and the only solution I can think of is to develop a custom driver with the DDK but as this requires a steep learning curve, I would hope to find an alternative solution.
Thanks
Dave...

Restriction on interrupt routines in linux kernel drivers

Every device driver book talks about not using functions that sleep in interrupt routines.
What issues occur by calling these functions from ISRs ?
A total lockdown of the kernel is the issue here. The kernel is in interrupt context when executing interrupt handlers, that is, the interrupt handler is not associated with any process (the current macro cannot be used).
If you are able to sleep, you would never be able to get back to the interrupted code, since the scheduler would not know how to get back to it.
Holding a lock in the interrupt handler, and then sleeping, allowing another process to run and then entering the interrupt handler again and trying to re-acquire the lock would deadlock the kernel.
If you try to read more about how the scheduling in the kernel works, you will soon realize why sleeping is a no go in certain contexts.

How do I "schedule an interrupt" on win32/intel architecture?

I'd like to figure out how to schedule a real ISR on normal win32 architecture (not Windows CE!)
Is it possible?
What do you mean by schedule? You can hook a Hardware interrupt (and you should save and call the old hook in most cases); you can trigger a HW interrupt manually - but there consequences when handling those; you can hook one of the timer int's, and implement a scheduling mechanism, but AFAIK you can't "schedule an ISR".

Resources