qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ying-Shiuan Pan <yingshiuan.pan@gmail.com>
To: qemu-devel@nongnu.org
Cc: wbarak@gmail.com, Ying-Shiuan Pan <yingshiuan.pan@gmail.com>,
	yspan@itri.org.tw
Subject: [Qemu-devel] [PATCH 3/4] virtio-mmio: start ioeventfd when status gets DRIVER_OK
Date: Thu,  6 Feb 2014 01:03:38 +0800	[thread overview]
Message-ID: <1391619819-10525-4-git-send-email-yingshiuan.pan@gmail.com> (raw)
In-Reply-To: <1391619819-10525-1-git-send-email-yingshiuan.pan@gmail.com>

Signed-off-by: Ying-Shiuan Pan <yspan@itri.org.tw>
---
 hw/virtio/virtio-mmio.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c
index f95b7dd..11964ee 100644
--- a/hw/virtio/virtio-mmio.c
+++ b/hw/virtio/virtio-mmio.c
@@ -122,6 +122,42 @@ static int virtio_mmio_set_host_notifier_internal(VirtIOMMIOProxy *proxy,
     return r;
 }
 
+static void virtio_mmio_start_ioeventfd(VirtIOMMIOProxy *proxy)
+{
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
+    int n, r;
+
+    if (proxy->ioeventfd_disabled ||
+        proxy->ioeventfd_started) {
+        return;
+    }
+
+    for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) {
+        if (!virtio_queue_get_num(vdev, n)) {
+            continue;
+        }
+
+        r = virtio_mmio_set_host_notifier_internal(proxy, n, true, true);
+        if (r < 0) {
+            goto assign_error;
+        }
+    }
+    proxy->ioeventfd_started = true;
+    return;
+
+assign_error:
+    while (--n >= 0) {
+        if (!virtio_queue_get_num(vdev, n)) {
+            continue;
+        }
+
+        r = virtio_mmio_set_host_notifier_internal(proxy, n, false, false);
+        assert(r >= 0);
+    }
+    proxy->ioeventfd_started = false;
+    error_report("%s: failed. Fallback to a userspace (slower).", __func__);
+}
+
 static void virtio_mmio_stop_ioeventfd(VirtIOMMIOProxy *proxy)
 {
     int r;
@@ -320,7 +356,16 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value,
         virtio_update_irq(vdev);
         break;
     case VIRTIO_MMIO_STATUS:
+        if (!(value & VIRTIO_CONFIG_S_DRIVER_OK)) {
+            virtio_mmio_stop_ioeventfd(proxy);
+        }
+
         virtio_set_status(vdev, value & 0xff);
+
+        if (value & VIRTIO_CONFIG_S_DRIVER_OK) {
+            virtio_mmio_start_ioeventfd(proxy);
+        }
+
         if (vdev->status == 0) {
             virtio_reset(vdev);
         }
-- 
1.8.1.2

  parent reply	other threads:[~2014-02-05 17:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-05 17:03 [Qemu-devel] [PATCH 0/4] ioeventfd support for virtio-mmio Ying-Shiuan Pan
2014-02-05 17:03 ` [Qemu-devel] [PATCH 1/4] virtio-mmio: introduce set_host_notifier() Ying-Shiuan Pan
2014-02-05 17:03 ` [Qemu-devel] [PATCH 2/4] virtio-mmio: introduce set_guest_notifiers Ying-Shiuan Pan
2014-02-05 17:03 ` Ying-Shiuan Pan [this message]
2014-02-05 17:03 ` [Qemu-devel] [PATCH 4/4] virtio-mmio: add a new property for ioeventfd Ying-Shiuan Pan
  -- strict thread matches above, loose matches on Subject: below --
2014-11-04 12:47 [Qemu-devel] [PATCH 0/4] ioeventfd support for virtio-mmio Shannon Zhao
2014-11-04 12:47 ` [Qemu-devel] [PATCH 3/4] virtio-mmio: start ioeventfd when status gets DRIVER_OK Shannon Zhao
2015-05-06  7:54 Pavel Fedin

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=1391619819-10525-4-git-send-email-yingshiuan.pan@gmail.com \
    --to=yingshiuan.pan@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=wbarak@gmail.com \
    --cc=yspan@itri.org.tw \
    /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).