Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux PCI Device Driver - Bus v. Kernel IRQ

I am writing a device driver for a PCIe card in Linux. I am trying to use interrupts in my driver.

Reading the "IRQ Line" section of the PCI configuration register (offset 0x3C) reports that the assigned IRQ line for the device is 11. lspci -b -vv also reports that my device's interrupt number is 11.

Heres where it gets weird... cat /sys/bus/pci/devices/<my_device>/irq reports that the interrupt number is 19. lspci -vv also reports that the interrupt number is 19.

Requesting 11 in my driver does not work. If I request 19 in the driver, I catch interrupts just fine.

What gives?

Thanks!!!

like image 975
s.brookes Avatar asked Mar 19 '13 21:03

s.brookes


People also ask

What is kernel IRQ?

An IRQ is an interrupt request from a device. Currently they can come in over a pin, or over a packet. Several devices may be connected to the same pin thus sharing an IRQ. An IRQ number is a kernel identifier used to talk about a hardware interrupt source.

What is PCI buses in Linux?

Peripheral Component Interconnect (PCI) is a local computer bus for attaching hardware devices in a computer and is part of the PCI Local Bus standard. The PCI bus supports the functions found on a processor bus but in a standardized format that is independent of any given processor's native bus.

Can two devices share an IRQ?

An IRQ conflict happens when two devices attempt to use the same IRQ number, and the operating system or motherboard has no mechanism for accommodating this. These conflicts were common in older versions of Windows, but occur only rarely in modern versions of the operating system.

What is PCI in kernel?

However, the primary focus is on the kernel functions that access Peripheral Component Interconnect (PCI) peripherals, because these days the PCI bus is the most commonly used peripheral bus on desktops and bigger computers. The bus is the one that is best supported by the kernel.


1 Answers

I believe that it has to do with the difference between "physical" and "virtual" IRQ lines. Because the processor has a limited number of physical IRQ lines it assigns virtual IRQ lines to allow the total number of PCI devices to exceed the number of physical lines.

In this instance, 19 is your virtual IRQ line (as recognized by the processor) while 11 is the physical line (as recognized by the PCI device).

By the way, you should probably really get the IRQ number from the struct pci_dev for that device since they're dynamically generated.

like image 178
Sean Madden Avatar answered Sep 18 '22 13:09

Sean Madden