All of lore.kernel.org
 help / color / mirror / Atom feed
* Enable MSI-X support in PCIe device.
@ 2020-10-23  3:32 Douglas Su
  2020-10-26  3:30 ` Douglas Su
  0 siblings, 1 reply; 2+ messages in thread
From: Douglas Su @ 2020-10-23  3:32 UTC (permalink / raw)
  To: QEMU Developers

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?


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Enable MSI-X support in PCIe device.
  2020-10-23  3:32 Enable MSI-X support in PCIe device Douglas Su
@ 2020-10-26  3:30 ` Douglas Su
  0 siblings, 0 replies; 2+ messages in thread
From: Douglas Su @ 2020-10-26  3:30 UTC (permalink / raw)
  To: QEMU Developers; +Cc: QEMU Developers

[-- Attachment #1: Type: text/plain, Size: 1567 bytes --]

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?


[-- Attachment #2: Type: text/html, Size: 3126 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-26  3:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-23  3:32 Enable MSI-X support in PCIe device Douglas Su
2020-10-26  3:30 ` Douglas Su

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.