1

I am trying to write a Kernel Module that I can use to service PCIe MSI interrupts. Right now I am having trouble trying to configure my interrupts and am trying to follow along with "Linux Device Drivers Ed. 3" The book states:

"The driver doesn't need to bother checking the interrupt number, because the value found in PCI_INTERRUPT_LINE is guaranteed to be the right one."

So of course this seems to be the logical way to setup my interrupts:

err = pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &myirq);
if(err)
{
    printk(KERN_WARNING "Could not get IRQ number\n");
    return err;
}
err = request_irq(myirq, fpga_isr, IRQF_SHARED, fpga_driver.name, dev);

Now this registers me for interrupt 60. I then go about using jTag to manually trigger an interrupt and I get a Kernel message saying that the interrupt does not have a handler attatched to it (interrupt 576). If I hardcode irq_line to 576 I then fail the request_irq.

What is the best way to find out my interrupt line? and why can I not get the IRQ that I need?

One more thing, during boot, my device is automatically set to IRQ pin 1 (Legacy interrupt A) which correseponds to irq line 572 which is also the value stored in dev->irq. If the boot sequence automatically set the IRQ to pin 0 (Legacy interrupts disabled) would dev->irq point to my MSI interrupt @ 576?

whh4000
  • 905
  • 1
  • 12
  • 30

1 Answers1

2

For MSI, you need to enable the MSI interrupt on your device first with pci_enable_msi. The MSI interrupt is not the same as the "standard PCI" interrupt. After calling pci_enable_msi, the interrupt number should be gotten from pci_dev->irq for calling request_irq. Look for an example in the kernel source tree.

More info in Documentation/PCI/MSI-HOWTO.txt

Gil Hamilton
  • 11,973
  • 28
  • 51
  • When I do this, I see I get the correct interrupt number now, but when I free_irq(dev->irq, dev); and then pci_disable_msi(dev); I get a cannot derefference NULL pointer error. Why would that be? – whh4000 Jun 17 '14 at 15:08
  • Not sure. Would have to see the stack trace. BTW, might want to enable CONFIG_FRAME_POINTER to make debugging with stack traces easier. – Gil Hamilton Jun 17 '14 at 20:50