Commit bbea6c7a authored by Jean-Philippe Brucker's avatar Jean-Philippe Brucker Committed by Will Deacon
Browse files

virtio: Clean up next_desc



The wmb() in next_desc seems out of place and the comments are
inaccurate. Remove the unnecessary barrier and clean up next_desc().

next_desc() is called by virt_queue__get_head_iov() when filling the iov
with desciptor addresses. It reads the descriptor's flag and next index.
The virt_queue__get_head_iov() only reads the direct and indirect
descriptors, and doesn't write any shared memory except from iov and
cursors that will be read by the caller.

As far as I can see, vhost (the kernel implementation of virtio device)
does well without any barrier here, so I think it might be safe to remove.
Signed-off-by: default avatarJean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent 15c4e1ef
......@@ -75,8 +75,8 @@ static inline bool virt_desc__test_flag(struct virt_queue *vq,
/*
* Each buffer in the virtqueues is actually a chain of descriptors. This
* function returns the next descriptor in the chain, or vq->vring.num if we're
* at the end.
* function returns the next descriptor in the chain, or max if we're at the
* end.
*/
static unsigned next_desc(struct virt_queue *vq, struct vring_desc *desc,
unsigned int i, unsigned int max)
......@@ -87,12 +87,10 @@ static unsigned next_desc(struct virt_queue *vq, struct vring_desc *desc,
if (!virt_desc__test_flag(vq, &desc[i], VRING_DESC_F_NEXT))
return max;
/* Check they're not leading us off end of descriptors. */
next = virtio_guest_to_host_u16(vq, desc[i].next);
/* Make sure compiler knows to grab that: we don't want it changing! */
wmb();
return next;
/* Ensure they're not leading us off end of descriptors. */
return min(next, max);
}
u16 virt_queue__get_head_iov(struct virt_queue *vq, struct iovec iov[], u16 *out, u16 *in, u16 head, struct kvm *kvm)
......
Supports Markdown
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