All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kurz <groug@kaod.org>
To: qemu-devel@nongnu.org
Cc: Greg Kurz <groug@kaod.org>, Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH] tests: virtio-9p: fix ISR dependence
Date: Fri, 08 Dec 2017 15:26:13 +0100	[thread overview]
Message-ID: <151274317380.5376.485467933490492379.stgit@bahia.lan> (raw)

Like other virtio tests, use the used ring APIs instead of assuming ISR
being set means the request has completed.

Signed-off-by: Greg Kurz <groug@kaod.org>
---
 tests/virtio-9p-test.c |   30 +++++++++++-------------------
 1 file changed, 11 insertions(+), 19 deletions(-)

diff --git a/tests/virtio-9p-test.c b/tests/virtio-9p-test.c
index ad33d963876f..ebd24b20f657 100644
--- a/tests/virtio-9p-test.c
+++ b/tests/virtio-9p-test.c
@@ -18,6 +18,8 @@
 #include "standard-headers/linux/virtio_pci.h"
 #include "hw/9pfs/9p.h"
 
+#define QVIRTIO_9P_TIMEOUT_US (10 * 1000 * 1000)
+
 static const char mount_tag[] = "qtest";
 
 typedef struct {
@@ -111,6 +113,7 @@ typedef struct {
     /* No r_size, it is hardcoded to P9_MAX_SIZE */
     size_t t_off;
     size_t r_off;
+    uint32_t free_head;
 } P9Req;
 
 static void v9fs_memwrite(P9Req *req, const void *addr, size_t len)
@@ -124,11 +127,6 @@ static void v9fs_memskip(P9Req *req, size_t len)
     req->r_off += len;
 }
 
-static void v9fs_memrewind(P9Req *req, size_t len)
-{
-    req->r_off -= len;
-}
-
 static void v9fs_memread(P9Req *req, void *addr, size_t len)
 {
     memread(req->r_msg + req->r_off, addr, len);
@@ -227,12 +225,12 @@ static P9Req *v9fs_req_init(QVirtIO9P *v9p, uint32_t size, uint8_t id,
 static void v9fs_req_send(P9Req *req)
 {
     QVirtIO9P *v9p = req->v9p;
-    uint32_t free_head;
 
     req->r_msg = guest_alloc(v9p->qs->alloc, P9_MAX_SIZE);
-    free_head = qvirtqueue_add(v9p->vq, req->t_msg, req->t_size, false, true);
+    req->free_head = qvirtqueue_add(v9p->vq, req->t_msg, req->t_size, false,
+                                    true);
     qvirtqueue_add(v9p->vq, req->r_msg, P9_MAX_SIZE, true, false);
-    qvirtqueue_kick(v9p->dev, v9p->vq, free_head);
+    qvirtqueue_kick(v9p->dev, v9p->vq, req->free_head);
     req->t_off = 0;
 }
 
@@ -250,19 +248,13 @@ static void v9fs_req_recv(P9Req *req, uint8_t id)
 {
     QVirtIO9P *v9p = req->v9p;
     P9Hdr hdr;
-    int i;
 
-    for (i = 0; i < 10; i++) {
-        qvirtio_wait_queue_isr(v9p->dev, v9p->vq, 1000 * 1000);
+    qvirtio_wait_used_elem(v9p->dev, v9p->vq, req->free_head,
+                           QVIRTIO_9P_TIMEOUT_US);
 
-        v9fs_memread(req, &hdr, 7);
-        hdr.size = ldl_le_p(&hdr.size);
-        hdr.tag = lduw_le_p(&hdr.tag);
-        if (hdr.size >= 7) {
-            break;
-        }
-        v9fs_memrewind(req, 7);
-    }
+    v9fs_memread(req, &hdr, 7);
+    hdr.size = ldl_le_p(&hdr.size);
+    hdr.tag = lduw_le_p(&hdr.tag);
 
     g_assert_cmpint(hdr.size, >=, 7);
     g_assert_cmpint(hdr.size, <=, P9_MAX_SIZE);

             reply	other threads:[~2017-12-08 14:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-08 14:26 Greg Kurz [this message]
2017-12-11 11:20 ` [Qemu-devel] [PATCH] tests: virtio-9p: fix ISR dependence Stefan Hajnoczi

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=151274317380.5376.485467933490492379.stgit@bahia.lan \
    --to=groug@kaod.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.