qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Enable MSI-X support in PCIe device.


From: Douglas Su
Subject: Re: Enable MSI-X support in PCIe device.
Date: Mon, 26 Oct 2020 03:30:21 +0000

I have tried to use msi only, but failed again. Is there and documentation details this?


From: Qemu-devel <qemu-devel-bounces+d0u9.su=outlook.com@nongnu.org> on behalf of Douglas Su <d0u9.su@outlook.com>
Sent: Thursday, October 22, 2020 20:32
To: QEMU Developers <qemu-devel@nongnu.org>
Subject: Enable MSI-X support in PCIe device.
 
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

[Prev in Thread] Current Thread [Next in Thread]