summaryrefslogtreecommitdiffstats
path: root/tools/virtio/ringtest/ring.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2017-10-26 03:48:01 +0200
committerMichael S. Tsirkin <mst@redhat.com>2018-01-31 00:47:35 +0100
commitf229a55c31a7e12a15c7b4dcf9a97a9bf7a72ce8 (patch)
treed1a66cb14384c15dceaf6c291a34e6e4d288086d /tools/virtio/ringtest/ring.c
parentvirtio: virtio_mmio: make of_device_ids const. (diff)
downloadlinux-f229a55c31a7e12a15c7b4dcf9a97a9bf7a72ce8.tar.xz
linux-f229a55c31a7e12a15c7b4dcf9a97a9bf7a72ce8.zip
virtio/ringtest: fix up need_event math
last kicked event index must be updated unconditionally: even if we don't need to kick, we do not want to re-check the same entry for events. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Cornelia Huck <cohuck@redhat.com> Acked-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'tools/virtio/ringtest/ring.c')
-rw-r--r--tools/virtio/ringtest/ring.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/tools/virtio/ringtest/ring.c b/tools/virtio/ringtest/ring.c
index 747c5dd47be8..2b9859beea65 100644
--- a/tools/virtio/ringtest/ring.c
+++ b/tools/virtio/ringtest/ring.c
@@ -188,16 +188,18 @@ bool enable_call()
void kick_available(void)
{
+ bool need;
+
/* Flush in previous flags write */
/* Barrier C (for pairing) */
smp_mb();
- if (!need_event(event->kick_index,
- guest.avail_idx,
- guest.kicked_avail_idx))
- return;
+ need = need_event(event->kick_index,
+ guest.avail_idx,
+ guest.kicked_avail_idx);
guest.kicked_avail_idx = guest.avail_idx;
- kick();
+ if (need)
+ kick();
}
/* host side */
@@ -253,14 +255,18 @@ bool use_buf(unsigned *lenp, void **bufp)
void call_used(void)
{
+ bool need;
+
/* Flush in previous flags write */
/* Barrier D (for pairing) */
smp_mb();
- if (!need_event(event->call_index,
+
+ need = need_event(event->call_index,
host.used_idx,
- host.called_used_idx))
- return;
+ host.called_used_idx);
host.called_used_idx = host.used_idx;
- call();
+
+ if (need)
+ call();
}