Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are MSI interrupts not shared?

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 ?

like image 747
valmiki Avatar asked Dec 20 '15 13:12

valmiki


People also ask

Can interrupts be shared between devices?

Stand-alone serial devices can also share interrupts. However, a shared interrupt can only be used by one device at a time.

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.

How does MSI interrupt work?

Message-signaled interrupts (MSIs) were introduced in the PCI 2.2 specification as an alternative to line-based interrupts. Instead of using a dedicated pin to trigger interrupts, devices that use MSIs trigger an interrupt by writing a value to a particular memory address.

How do I enable MSI interrupts?

Use the Interrupt Management\MessageSignaledInterruptProperties subkey of the device's hardware key to enable MSI support. The MSISupported entry of Interrupt Management\MessageSignaledInterruptProperties is a REG_DWORD value that determines whether the device supports MSIs. Set MSISupported to 1 to enable MSI support.


2 Answers

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.

like image 72
CL. Avatar answered Jan 02 '23 23:01

CL.


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.

like image 21
Kaz Avatar answered Jan 02 '23 23:01

Kaz