thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
ed5979
From 181705090c9963c2da97811838ace5bb058737c6 Mon Sep 17 00:00:00 2001
ed5979
From: Cindy Lu <lulu@redhat.com>
ed5979
Date: Thu, 22 Dec 2022 15:04:50 +0800
ed5979
Subject: [PATCH 09/31] virtio-mmio: add support for configure interrupt
ed5979
MIME-Version: 1.0
ed5979
Content-Type: text/plain; charset=UTF-8
ed5979
Content-Transfer-Encoding: 8bit
ed5979
ed5979
RH-Author: Cindy Lu <lulu@redhat.com>
ed5979
RH-MergeRequest: 132: vhost-vdpa: support config interrupt in vhost-vdpa
ed5979
RH-Bugzilla: 1905805
ed5979
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
ed5979
RH-Acked-by: Eugenio PĂ©rez <eperezma@redhat.com>
ed5979
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
ed5979
RH-Commit: [9/10] 742cc2b425ffd7bbd393772526e7481446ee131c (lulu6/qemu-kvm3)
ed5979
ed5979
https://bugzilla.redhat.com/show_bug.cgi?id=1905805
ed5979
Add configure interrupt support in virtio-mmio bus.
ed5979
add function to set configure guest notifier.
ed5979
ed5979
Signed-off-by: Cindy Lu <lulu@redhat.com>
ed5979
Message-Id: <20221222070451.936503-10-lulu@redhat.com>
ed5979
Acked-by: Jason Wang <jasowang@redhat.com>
ed5979
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
ed5979
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
ed5979
(cherry picked from commit cd336e834620ea78edef049c3567f312974e475b)
ed5979
Signed-off-by: Cindy Lu <lulu@redhat.com>
ed5979
---
ed5979
 hw/virtio/virtio-mmio.c | 27 +++++++++++++++++++++++++++
ed5979
 1 file changed, 27 insertions(+)
ed5979
ed5979
diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c
ed5979
index d240efef97..103260ec15 100644
ed5979
--- a/hw/virtio/virtio-mmio.c
ed5979
+++ b/hw/virtio/virtio-mmio.c
ed5979
@@ -670,7 +670,30 @@ static int virtio_mmio_set_guest_notifier(DeviceState *d, int n, bool assign,
ed5979
 
ed5979
     return 0;
ed5979
 }
ed5979
+static int virtio_mmio_set_config_guest_notifier(DeviceState *d, bool assign,
ed5979
+                                                 bool with_irqfd)
ed5979
+{
ed5979
+    VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d);
ed5979
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
ed5979
+    VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
ed5979
+    EventNotifier *notifier = virtio_config_get_guest_notifier(vdev);
ed5979
+    int r = 0;
ed5979
 
ed5979
+    if (assign) {
ed5979
+        r = event_notifier_init(notifier, 0);
ed5979
+        if (r < 0) {
ed5979
+            return r;
ed5979
+        }
ed5979
+        virtio_config_set_guest_notifier_fd_handler(vdev, assign, with_irqfd);
ed5979
+    } else {
ed5979
+        virtio_config_set_guest_notifier_fd_handler(vdev, assign, with_irqfd);
ed5979
+        event_notifier_cleanup(notifier);
ed5979
+    }
ed5979
+    if (vdc->guest_notifier_mask && vdev->use_guest_notifier_mask) {
ed5979
+        vdc->guest_notifier_mask(vdev, VIRTIO_CONFIG_IRQ_IDX, !assign);
ed5979
+    }
ed5979
+    return r;
ed5979
+}
ed5979
 static int virtio_mmio_set_guest_notifiers(DeviceState *d, int nvqs,
ed5979
                                            bool assign)
ed5979
 {
ed5979
@@ -692,6 +715,10 @@ static int virtio_mmio_set_guest_notifiers(DeviceState *d, int nvqs,
ed5979
             goto assign_error;
ed5979
         }
ed5979
     }
ed5979
+    r = virtio_mmio_set_config_guest_notifier(d, assign, with_irqfd);
ed5979
+    if (r < 0) {
ed5979
+        goto assign_error;
ed5979
+    }
ed5979
 
ed5979
     return 0;
ed5979
 
ed5979
-- 
ed5979
2.31.1
ed5979