qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Cindy Lu <lulu@redhat.com>
To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com,
	kraxel@redhat.com, dgilbert@redhat.com, stefanha@redhat.com,
	arei.gonglei@huawei.com, marcandre.lureau@redhat.com
Cc: qemu-devel@nongnu.org
Subject: [PATCH v9 06/10] virtio: add support for configure interrupt
Date: Thu, 30 Sep 2021 10:33:44 +0800	[thread overview]
Message-ID: <20210930023348.17770-7-lulu@redhat.com> (raw)
In-Reply-To: <20210930023348.17770-1-lulu@redhat.com>

Add the support for configure interrupt in virtio
add notifier_read and set_fd_handler function

Signed-off-by: Cindy Lu <lulu@redhat.com>
---
 hw/virtio/virtio.c         | 29 +++++++++++++++++++++++++++++
 include/hw/virtio/virtio.h |  4 ++++
 2 files changed, 33 insertions(+)

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 31987b103b..bd222edc9e 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -3531,7 +3531,14 @@ static void virtio_queue_guest_notifier_read(EventNotifier *n)
         virtio_irq(vq);
     }
 }
+static void virtio_config_guest_notifier_read(EventNotifier *n)
+{
+    VirtIODevice *vdev = container_of(n, VirtIODevice, config_notifier);
 
+    if (event_notifier_test_and_clear(n)) {
+        virtio_notify_config(vdev);
+    }
+}
 void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,
                                                 bool with_irqfd)
 {
@@ -3548,6 +3555,23 @@ void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,
     }
 }
 
+void virtio_config_set_guest_notifier_fd_handler(VirtIODevice *vdev,
+                                                 bool assign, bool with_irqfd)
+{
+    EventNotifier *n;
+    n = &vdev->config_notifier;
+    if (assign && !with_irqfd) {
+        event_notifier_set_handler(n, virtio_config_guest_notifier_read);
+    } else {
+        event_notifier_set_handler(n, NULL);
+    }
+    if (!assign) {
+        /* Test and clear notifier before closing it,*/
+        /* in case poll callback didn't have time to run. */
+        virtio_config_guest_notifier_read(n);
+    }
+}
+
 EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq)
 {
     return &vq->guest_notifier;
@@ -3621,6 +3645,11 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq)
     return &vq->host_notifier;
 }
 
+EventNotifier *virtio_config_get_guest_notifier(VirtIODevice *vdev)
+{
+    return &vdev->config_notifier;
+}
+
 void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled)
 {
     vq->host_notifier_enabled = enabled;
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 2766c293f4..9e02d155a1 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -110,6 +110,7 @@ struct VirtIODevice
     bool use_guest_notifier_mask;
     AddressSpace *dma_as;
     QLIST_HEAD(, VirtQueue) *vector_queues;
+    EventNotifier config_notifier;
 };
 
 struct VirtioDeviceClass {
@@ -312,11 +313,14 @@ uint16_t virtio_get_queue_index(VirtQueue *vq);
 EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq);
 void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,
                                                 bool with_irqfd);
+void virtio_config_set_guest_notifier_fd_handler(VirtIODevice *vdev,
+                                                 bool assign, bool with_irqfd);
 int virtio_device_start_ioeventfd(VirtIODevice *vdev);
 int virtio_device_grab_ioeventfd(VirtIODevice *vdev);
 void virtio_device_release_ioeventfd(VirtIODevice *vdev);
 bool virtio_device_ioeventfd_enabled(VirtIODevice *vdev);
 EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq);
+EventNotifier *virtio_config_get_guest_notifier(VirtIODevice *vdev);
 void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled);
 void virtio_queue_host_notifier_read(EventNotifier *n);
 void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx,
-- 
2.21.3



  parent reply	other threads:[~2021-09-30  2:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-30  2:33 [PATCH v9 00/10] vhost-vdpa: add support for configure interrupt Cindy Lu
2021-09-30  2:33 ` [PATCH v9 01/10] virtio: introduce macro IRTIO_CONFIG_IRQ_IDX Cindy Lu
2021-10-19  6:47   ` Michael S. Tsirkin
2021-09-30  2:33 ` [PATCH v9 02/10] virtio-pci: decouple notifier from interrupt process Cindy Lu
2021-09-30  2:33 ` [PATCH v9 03/10] virtio-pci: decouple the single vector from the " Cindy Lu
2021-09-30  2:33 ` [PATCH v9 04/10] vhost: add new call back function for config interrupt Cindy Lu
2021-10-19  6:52   ` Michael S. Tsirkin
2021-10-20  2:29     ` Cindy Lu
2021-09-30  2:33 ` [PATCH v9 05/10] vhost-vdpa: add support for config interrupt call back Cindy Lu
2021-10-19  6:54   ` Michael S. Tsirkin
2021-10-20  3:20     ` Cindy Lu
2021-09-30  2:33 ` Cindy Lu [this message]
2021-09-30  2:33 ` [PATCH v9 07/10] virtio-net: add support for configure interrupt Cindy Lu
2021-09-30  2:33 ` [PATCH v9 08/10] vhost: " Cindy Lu
2021-09-30  2:33 ` [PATCH v9 09/10] virtio-mmio: " Cindy Lu
2021-09-30  2:33 ` [PATCH v9 10/10] virtio-pci: " Cindy Lu
2021-10-19  6:39   ` Michael S. Tsirkin
2021-10-19  6:50   ` Michael S. Tsirkin
2021-10-19  6:56 ` [PATCH v9 00/10] vhost-vdpa: " Michael S. Tsirkin
2021-10-20  2:31   ` Cindy Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210930023348.17770-7-lulu@redhat.com \
    --to=lulu@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=dgilbert@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).