0

I am not a driver programmer, I don't have a clear picture of how linux assign irq number for pcie devices.

From an NIC driver example, it seems Linux already know which irq number should be used before the function of 'probe' or 'open' was executed.

ex: https://github.com/torvalds/linux/blob/4608f064532c28c0ea3c03fe26a3a5909852811a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c#L6608

err = ixgbe_request_irq(adapter);

ixgbe can get irq number by using the data of the 'adapter' variable, it means the irq value already inside adapter structure, it is not a generated number, it is an already existed value.

if it is read from pci/pcie configuration space, wasn't it very easy to conflict with other devices?

if it is generated/arrange by kernel, how the irq number already inside the 'adapter' variable? ( or it is assigned by BIOS ? )

For interrupt for MSI, it seems generated by kernel ??

--

In my understanding, the irq number should be read from Interrupt Line Register (offset 3Ch) in PCIe configuration space, I guess that's why kerenl already know which irq number should be used, and Interrupt Line Register should be updated by BIOS ( my guess ) during boot, but there still a virtual IRQ ( when lspci without -b ), and seems MSI has another irq (?), are they common resource like memory to be arranged ?

1

for legacy interrupt, the irq value was read from the configuration space, however, the irq value was mostly assigned by BIOS.

more info for this part: http://tldp.org/HOWTO/Plug-and-Play-HOWTO-7.html

For MSI/MSI-X interrupt, it is done by allocation.

ex: pci_alloc_irq_vectors() https://www.kernel.org/doc/Documentation/PCI/MSI-HOWTO.txt

  • "By the time Linux boots, the computer’s firmware has already assigned a unique interrupt number to the device, and the driver just needs to use it." -- ldd3, page.317 – Mark Sep 7 '18 at 5:55
  • "result = pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &myirq);", ldd3, page.318. – Mark Sep 7 '18 at 5:56
  • "When the computer is booted, the firmware scans its PCI devices and sets the register (PCI_INTERRUPT_LINE register) for each device according to how the interrupt pin is routed for its PCI slot.", ldd3.page 318. – Mark Sep 7 '18 at 6:21
0

It depends a lot on the machine we are talking about... on PCs nowadays devices assign IRQ numbers on the fly when configured.

To delve into the topic, take a peek at "Linux Device Drivers" (yes, it is quite dated, but much of what it has to say still applies).

0

For MSI-X, see the comments in acpi_pci_irq_check_entry().

/*
 * Type 1: Dynamic
 * ---------------
 * The 'source' field specifies the PCI interrupt link device used to
 * configure the IRQ assigned to this slot|dev|pin.  The 'source_index'
 * indicates which resource descriptor in the resource template (of
 * the link device) this interrupt is allocated from.
 * 
 * NOTE: Don't query the Link Device for IRQ information at this time
 *       because Link Device enumeration may not have occurred yet
 *       (e.g. exists somewhere 'below' this _PRT entry in the ACPI
 *       namespace).
 */

/*
 * Type 2: Static
 * --------------
 * The 'source' field is NULL, and the 'source_index' field specifies
 * the IRQ value, which is hardwired to specific interrupt inputs on
 * the interrupt controller.
 */

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.