From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LkL3h-0008U6-SZ for qemu-devel@nongnu.org; Thu, 19 Mar 2009 12:25:29 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LkL3d-0008OW-0P for qemu-devel@nongnu.org; Thu, 19 Mar 2009 12:25:29 -0400 Received: from [199.232.76.173] (port=36910 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LkL3c-0008OF-M1 for qemu-devel@nongnu.org; Thu, 19 Mar 2009 12:25:24 -0400 Received: from g4t0016.houston.hp.com ([15.201.24.19]:38945) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LkL3c-0000uJ-As for qemu-devel@nongnu.org; Thu, 19 Mar 2009 12:25:24 -0400 From: Alex Williamson Date: Thu, 19 Mar 2009 10:21:59 -0600 Message-ID: <20090319162118.24068.98794.stgit@kvm.aw> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH] qemu:virtio: Allow guest to defer VIRTIO_F_NOTIFY_ON_EMPTY Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: alex.williamson@hp.com, kvm@vger.kernel.org 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 --- hw/virtio.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) 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;