To use MSI-X interrupt in my PCIe device, In realize() function I make a MSIX 
initialization like this:

#define MYDEV_MSIX_VEC_NUM 5

void realize() {
    memory_region_init(&mydev->msix, OBJECT(edu), "mydev-msix",
                       MYDEV_MSIX_SIZE);
    pci_register_bar(pdev, MYDEV_MSIX_IDX,
                     PCI_BASE_ADDRESS_SPACE_MEMORY, &mydev->msix);

    rv = msix_init(pdev, MYDEV_MSIX_VEC_NUM,
                   &edu->msix, MYDEV_MSIX_IDX, MYDEV_MSIX_TABLE,
                   &edu->msix, MYDEV_MSIX_IDX, MYDEV_MSIX_PBA,
                   0, errp);
}

After this, a simple logic is added  to trigger interrupt by writing command to 
a specific BAR0 address.

void trigger() {
    msix_notify(pdev, 1);         // send vector 1 to msix
}

In the OS driver, MSIX is enabled via `pci_alloc_irq_vectors()`, which is 
detailed in Linux Kernel's documentation `Documentation/PCI/msi-howto.rst` (I 
use kernel 5.7).

It is correct to obtain the number of vector from that function but failed to 
receive interrupt from device. The IRQ, which is returned from 
`pci_irq_vector`, is registered via `request_irq()` in the deriver.

Can anyone give a clue?

Reply via email to