diff mbox series

misc: edu: add MSI-X interrupt generation aswell

Message ID 20210812113230.2462428-1-narmstrong@baylibre.com (mailing list archive)
State New, archived
Headers show
Series misc: edu: add MSI-X interrupt generation aswell | expand

Commit Message

Neil Armstrong Aug. 12, 2021, 11:32 a.m. UTC
Add MSI-X aswell since either MSI or MSI-X are optional and
MSI can still be used without any issues.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 hw/misc/edu.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/hw/misc/edu.c b/hw/misc/edu.c
index e935c418d4..5d0643e1bd 100644
--- a/hw/misc/edu.c
+++ b/hw/misc/edu.c
@@ -27,6 +27,7 @@ 
 #include "hw/pci/pci.h"
 #include "hw/hw.h"
 #include "hw/pci/msi.h"
+#include "hw/pci/msix.h"
 #include "qemu/timer.h"
 #include "qom/object.h"
 #include "qemu/main-loop.h" /* iothread mutex */
@@ -77,6 +78,11 @@  struct EduState {
     uint64_t dma_mask;
 };
 
+static bool edu_msix_enabled(EduState *edu)
+{
+    return msix_enabled(&edu->pdev);
+}
+
 static bool edu_msi_enabled(EduState *edu)
 {
     return msi_enabled(&edu->pdev);
@@ -86,7 +92,9 @@  static void edu_raise_irq(EduState *edu, uint32_t val)
 {
     edu->irq_status |= val;
     if (edu->irq_status) {
-        if (edu_msi_enabled(edu)) {
+        if (edu_msix_enabled(edu)) {
+            msix_notify(&edu->pdev, 0);
+        } else if (edu_msi_enabled(edu)) {
             msi_notify(&edu->pdev, 0);
         } else {
             pci_set_irq(&edu->pdev, 1);
@@ -369,6 +377,10 @@  static void pci_edu_realize(PCIDevice *pdev, Error **errp)
     if (msi_init(pdev, 0, 1, true, false, errp)) {
         return;
     }
+    if (msix_init_exclusive_bar(pdev, 1, 1, errp)) {
+        return;
+    }
+    msix_vector_use(pdev, 0);
 
     timer_init_ms(&edu->dma_timer, QEMU_CLOCK_VIRTUAL, edu_dma_timer, edu);
 
@@ -397,6 +409,7 @@  static void pci_edu_uninit(PCIDevice *pdev)
 
     timer_del(&edu->dma_timer);
     msi_uninit(pdev);
+    msix_uninit_exclusive_bar(pdev);
 }
 
 static void edu_instance_init(Object *obj)