diff mbox

qemu:virtio: Allow guest to defer VIRTIO_F_NOTIFY_ON_EMPTY

Message ID 20090319162118.24068.98794.stgit@kvm.aw (mailing list archive)
State New, archived
Headers show

Commit Message

Alex Williamson March 19, 2009, 4:21 p.m. UTC
There may be cases where the guest does not want the avail queue
interrupt, even when it's empty.  For the virtio-net case, the
guest may use a different buffering scheme or decide polling for
used buffers is more efficient.  This can be accomplished by simply
checking for whether the guest has acknowledged the existing notify
on empty flag.

Signed-off-by: Alex Williamson <alex.williamson@hp.com>
---

 hw/virtio.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Anthony Liguori March 20, 2009, 5:31 p.m. UTC | #1
Alex Williamson wrote:
> There may be cases where the guest does not want the avail queue
> interrupt, even when it's empty.  For the virtio-net case, the
> guest may use a different buffering scheme or decide polling for
> used buffers is more efficient.  This can be accomplished by simply
> checking for whether the guest has acknowledged the existing notify
> on empty flag.
>
> Signed-off-by: Alex Williamson <alex.williamson@hp.com>
>   

Applied to trunk and stable.  Thanks.

Regards,

Anthony Liguori

>   

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/hw/virtio.c b/hw/virtio.c
index b94ab0f..08ea16d 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -726,9 +726,10 @@  VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
 
 void virtio_notify(VirtIODevice *vdev, VirtQueue *vq)
 {
-    /* Always notify when queue is empty */
-    if ((vq->inuse || vring_avail_idx(vq) != vq->last_avail_idx) &&
-        (vring_avail_flags(vq) & VRING_AVAIL_F_NO_INTERRUPT))
+    /* Always notify when queue is empty (when feature acknowledge) */
+    if ((vring_avail_flags(vq) & VRING_AVAIL_F_NO_INTERRUPT) &&
+        (!(vdev->features & (1 << VIRTIO_F_NOTIFY_ON_EMPTY)) ||
+         (vq->inuse || vring_avail_idx(vq) != vq->last_avail_idx)))
         return;
 
     vdev->isr |= 0x01;