6

Can any body tell why MSI interrupts are not shareable in linux.

PIN based interrupts can be shared by devices, but MSI interrupts are not shared by devices, each device gets its own MSI IRQ number. Why can't MSI interrupts be shared ?

halfdan
  • 31,036
  • 8
  • 73
  • 85
valmiki
  • 631
  • 9
  • 20

2 Answers2

5

The old INTx interrupts have two problematic properties:

  1. Each INTx signal requires a separate signal line in hardware; and
  2. the interrupt signal is independent of the other data signals, and this is sent asynchronously.

The consequences are that

  1. multiple devices and drivers need to be able to share interrupts (the interrupt handler needs to check if its device actually raised the interrupt); and
  2. when a driver receives an interrupt, it needs to do a read of some device register to ensure that any previous DMA writes made by the device are visible on the CPU.

Typically, both cases are handled by the driver reading its device's interrupt status register.

Message-Signaled Interrupts do not require a separate signal line but are sent as a message over the data bus. This means that the same hardware can support many more interrupts (so sharing it not necessary), and that the interrupt message is automatically synchronized with any DMA accesses. As a consequence, the interrupt handler does not need to do anything; the interrupt is guaranteed to come from its device, and DMA'd data is guaranteed to have already arrived.

If some drivers were written to share some MSI, the interrupt handler would again have to check whether the interrupt actually came from its own device, and there would be no advantage over INTx interrupts.

MSIs are not shared because it would not be possible, but because it is not necessary.


Please note that sharing an MSI is actually possible: as seen in this excerpt from /proc/interrupts, the Advanced Error Reporting, Power Management Events, and hotplugging drivers share one interrupt:

64:          0          0   PCI-MSI-edge      aerdrv, PCIe PME, pciehp

These drivers are actually attached to the same device, but they still behave similar to INTx drivers, i.e., they register their interrupt with IRQF_SHARED, and the interrupt handlers check whether it was their own function that raised the interrupt.

CL.
  • 158,085
  • 15
  • 181
  • 214
4

Interrupt sharing is a hack due to resource constraints, like not having enough physical IRQ lines for each device that wants attention. If interrupts are represented by messages that have a large ID space, why would you do that?

"That" meaning: giving them the same identity so that devices then have to be probed to figure out which of the ones clashing to the same ID actually interrupted.

In fact, we would sometimes like to have multiple interrupts for one device. For instance, it's useful if the interrupt ID tells us not only which device interrupted by also why: like is it due to the arrival of input, or the draining of an output buffer? If interrupt lines are "cheap" because they are just software ID's with lots of bits, we can have that.

Kaz
  • 48,579
  • 8
  • 85
  • 132