interrupts in PCI Linux driver - Linux
This is a discussion on interrupts in PCI Linux driver - Linux ; Hi,
I am having problems handling interrupts in a driver for a PCI device.
The problem I see is I tell the driver to handle an interrupt that is
not the right one. I don't know how to get the ...
-
interrupts in PCI Linux driver
Hi,
I am having problems handling interrupts in a driver for a PCI device.
The problem I see is I tell the driver to handle an interrupt that is
not the right one. I don't know how to get the right interrupt number
my driver has to respond to.
This is the piece of driver code where I request an interrupt number:
//Here I ask the PCI device which interrupt number or interrupt line it
is assigned to
pci_read_config_byte(gp_pci_struct, PCI_INTERRUPT_LINE, &irq_assigned);
//And then I request this same interrupt number
g_irq_requested = irq_assigned;
result = request_irq(g_irq_requested, (void *)interrupt_handler,
SA_INTERRUPT | SA_SHIRQ, "some_string", (void *)gp_pci_struct);
Now, in my case, irq_assigned turns to be equal to 11 or 0xb in hex but
when the device starts interrupting the interrupts get routed to number
153. Since the driver only responds to interrupt number 11 it does not
see the device interrupts. I see that the device is using interrupt
number 153 by looking at /proc/interrupts.
I have run some commands to see which is the right interrupt number for
my device. When I run "lscpi -vv" I see the following information
relevant to my device:
04:01.0
Interrupt: pin A routed to IRQ 153
However, when I do "setpci -s 04:01:0 INTERRUPT_LINE" to see the
interrupt numer I get 0x0b as result which is the same number I get in
the driver when calling the pci_read_config_byte() function.
So I guess I am missing something here but I don't know what it is. Any
suggestion is appreciated.
Robert Ll
-
Re: interrupts in PCI Linux driver
I found the solution reading the struct pci_dev definition in the pci.h
file:
struct pci_dev {
...
..
/*
* Instead of touching interrupt line and base address registers
* directly, use the values stored here. They might be different!
*/
unsigned int irq;
Robert Lluís ha escrit:
> Hi,
>
> I am having problems handling interrupts in a driver for a PCI device.
> The problem I see is I tell the driver to handle an interrupt that is
> not the right one. I don't know how to get the right interrupt number
> my driver has to respond to.
> This is the piece of driver code where I request an interrupt number:
>
> //Here I ask the PCI device which interrupt number or interrupt line it
> is assigned to
>
> pci_read_config_byte(gp_pci_struct, PCI_INTERRUPT_LINE, &irq_assigned);
>
> //And then I request this same interrupt number
>
> g_irq_requested = irq_assigned;
>
> result = request_irq(g_irq_requested, (void *)interrupt_handler,
> SA_INTERRUPT | SA_SHIRQ, "some_string", (void *)gp_pci_struct);
>
>
> Now, in my case, irq_assigned turns to be equal to 11 or 0xb in hex but
> when the device starts interrupting the interrupts get routed to number
> 153. Since the driver only responds to interrupt number 11 it does not
> see the device interrupts. I see that the device is using interrupt
> number 153 by looking at /proc/interrupts.
>
> I have run some commands to see which is the right interrupt number for
> my device. When I run "lscpi -vv" I see the following information
> relevant to my device:
> 04:01.0
> Interrupt: pin A routed to IRQ 153
>
> However, when I do "setpci -s 04:01:0 INTERRUPT_LINE" to see the
> interrupt numer I get 0x0b as result which is the same number I get in
> the driver when calling the pci_read_config_byte() function.
>
> So I guess I am missing something here but I don't know what it is. Any
> suggestion is appreciated.
>
> Robert Ll