Commit a311650a authored by Michael S. Tsirkin's avatar Michael S. Tsirkin

virtio/ringtest: virtio_ring: 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.
Reported-by: default avatarCornelia Huck <cohuck@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Reviewed-by: default avatarJens Freimann <jfreimann@redhat.com>
parent f229a55c
...@@ -225,16 +225,18 @@ bool enable_call() ...@@ -225,16 +225,18 @@ bool enable_call()
void kick_available(void) void kick_available(void)
{ {
bool need;
/* Flush in previous flags write */ /* Flush in previous flags write */
/* Barrier C (for pairing) */ /* Barrier C (for pairing) */
smp_mb(); smp_mb();
if (!vring_need_event(vring_avail_event(&ring), need = vring_need_event(vring_avail_event(&ring),
guest.avail_idx, guest.avail_idx,
guest.kicked_avail_idx)) guest.kicked_avail_idx);
return;
guest.kicked_avail_idx = guest.avail_idx; guest.kicked_avail_idx = guest.avail_idx;
kick(); if (need)
kick();
} }
/* host side */ /* host side */
...@@ -316,14 +318,16 @@ bool use_buf(unsigned *lenp, void **bufp) ...@@ -316,14 +318,16 @@ bool use_buf(unsigned *lenp, void **bufp)
void call_used(void) void call_used(void)
{ {
bool need;
/* Flush in previous flags write */ /* Flush in previous flags write */
/* Barrier D (for pairing) */ /* Barrier D (for pairing) */
smp_mb(); smp_mb();
if (!vring_need_event(vring_used_event(&ring), need = vring_need_event(vring_used_event(&ring),
host.used_idx, host.used_idx,
host.called_used_idx)) host.called_used_idx);
return;
host.called_used_idx = host.used_idx; host.called_used_idx = host.used_idx;
call(); if (need)
call();
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment