qemu-devel
[Top][All Lists]
Advanced

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

Re: [RFC PATCH v4 17/20] vhost: Use VRING_AVAIL_F_NO_INTERRUPT at device


From: Jason Wang
Subject: Re: [RFC PATCH v4 17/20] vhost: Use VRING_AVAIL_F_NO_INTERRUPT at device call on shadow virtqueue
Date: Wed, 13 Oct 2021 12:36:44 +0800
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.0


在 2021/10/1 下午3:06, Eugenio Pérez 写道:
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>


Commit log please.

Thanks


---
  hw/virtio/vhost-shadow-virtqueue.c | 24 +++++++++++++++++++++++-
  1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/hw/virtio/vhost-shadow-virtqueue.c 
b/hw/virtio/vhost-shadow-virtqueue.c
index 775f8d36a0..2fd0bab75d 100644
--- a/hw/virtio/vhost-shadow-virtqueue.c
+++ b/hw/virtio/vhost-shadow-virtqueue.c
@@ -60,6 +60,9 @@ typedef struct VhostShadowVirtqueue {
/* Next head to consume from device */
      uint16_t used_idx;
+
+    /* Cache for the exposed notification flag */
+    bool notification;
  } VhostShadowVirtqueue;
/* If the device is using some of these, SVQ cannot communicate */
@@ -105,6 +108,24 @@ bool vhost_svq_valid_device_features(uint64_t 
*dev_features)
      return r;
  }
+static void vhost_svq_set_notification(VhostShadowVirtqueue *svq, bool enable)
+{
+    uint16_t notification_flag;
+
+    if (svq->notification == enable) {
+        return;
+    }
+
+    notification_flag = cpu_to_le16(VRING_AVAIL_F_NO_INTERRUPT);
+
+    svq->notification = enable;
+    if (enable) {
+        svq->vring.avail->flags &= ~notification_flag;
+    } else {
+        svq->vring.avail->flags |= notification_flag;
+    }
+}
+
  static void vhost_vring_write_descs(VhostShadowVirtqueue *svq,
                                      const struct iovec *iovec,
                                      size_t num, bool more_descs, bool write)
@@ -273,7 +294,7 @@ static void vhost_svq_handle_call_no_test(EventNotifier *n)
      do {
          unsigned i = 0;
- /* TODO: Use VRING_AVAIL_F_NO_INTERRUPT */
+        vhost_svq_set_notification(svq, false);
          while (true) {
              g_autofree VirtQueueElement *elem = vhost_svq_get_buf(svq);
              if (!elem) {
@@ -286,6 +307,7 @@ static void vhost_svq_handle_call_no_test(EventNotifier *n)
virtqueue_flush(vq, i);
          event_notifier_set(&svq->guest_call_notifier);
+        vhost_svq_set_notification(svq, true);
      } while (vhost_svq_more_used(svq));
  }




reply via email to

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