enable/disable PCI interrupts

Nov 13, 2015 1 Replies

As a course of learning linux device drivers, I'm implementing a PCIe driver, and I'd like to understand at what level the interrupts can be or should be enabled/disabled. I intentionally do not specify OS, as I'm assuming it should be relevant for any platform. By levels I mean the following:



a) OS specific interrupts handling framework



b) Interrupts can be disabled or enabled in the PCI/PCIe configuration space registers, e.g. COMMAND register



c) Interrupts also can be masked at device level, for instance we can configure device not trigger certain interrupts to the host



I understand that whatever interrupt type is being used on PCIe (INTx emulation, MSI or MSI-X), it has to be delivered to the host OS. So my question is really -- do we actually have to enable or disable interrupts on every layer, or it's sufficient only at the closest to hardware, e.g. in relevant PCI registers?



Mark

Hi,

In Linux drivers I need to do enable the PCI device in the probe (example:

formatting link
) Then, when i want to be able to receive interrupts, I have to register the interrupt handler (request_irq, devm_request_irq or request_threaded_irq). (example:
formatting link
) After that, I can control interrupts using the device resources: (example:
formatting link
formatting link
) Of course at the end I need to deregister the interrupt handler (example:
formatting link
) and disable the device (example:
formatting link
)

The above was one of the simplest PCI drivers. You can also analyse more co mplex examples.

In case of PCIe devices you may need to switch on and off the MSI modes: (examples:

formatting link
formatting link
formatting link
)

Of course the above is very simplified description. You can find more information in:

formatting link

particularly in:

formatting link
and
formatting link

HTH & Regards, Wojtek

W dniu pi?tek, 13 listopada 2015 14:55:55 UTC+1 u?ytkownik Mark n apisa?:

ace

on

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required