简体   繁体   中英

Linux: Force a PCIe MSI interrupt to trigger from the command line

Background

I am having an issue where on a 32-bit Linux kernel my PCIe driver, with multi-MSI, and custom hardware device would work perfectly, now I've moved to a 64-bit iMX8MM CPU and MSI interrupts no longer trigger. The driver registers the interrupts correctly without any errors and I can view the output of cat /proc/interrupts and see all MSI vectors listed for my driver along with their interrupt count, which is zero. There is a bridge but /sys/bus/pci/devices/<address>/msi_bus has a 1 so it is enabled. Everything from lspci -vv looks in order and CONFIG_PCI_MSI was applied to the kernel. I am able to read and write memory buffers on the PCIe device so communications works correctly, I just can't get MSI interrupts to trigger. This is the exact same driver code running on the 32-bit CPU, which worked, and was recompiled on the new 64-bit CPU.

Question

How do I force an MSI interrupt on the system to see if Linux will pick it up and execute my code? From lspci -vv I can see the MSI address and I know the MSI vector value to write. So where do I write this on the system? I've looked at /dev/mem and other areas where I could hopefully do an echo 0x1 > <address> , or some other command line function, to write a value and trigger it. Where/how do I write to trigger a specific MSI interrupt?

An MSI can't be triggered by a CPU; the dword write that triggers the interrupt is only recognized as an interrupt when it comes from a device.

A CPU can initiate an interrupt in a similar way by writing to the local APIC ICR register. This can only be done from the kernel, and as far as I know there is no existing kernel service to allow injecting an arbitrary interrupt. Maybe you can add a service to your kernel driver to do it. (Note, as a temporary debugging aid; this would be terribly inappropriate to leave in place in a driver.)

The fields of the ICR aren't identical to those of an MSI, but they are similar. It should be straightforward to compare the documentation for the two to map one to the other.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM