dm: virtio: make sure VQ_ALLOC is set after initialization

Make sure VQ_ALLOC is visible only after vq is completely initialized.

This ensures vq_ring_ready() is reliable when it returns true.

Tracked-On: #2763
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
This commit is contained in:
Peter Fang 2019-03-17 02:02:52 -07:00 committed by wenlingz
parent 6be9f15aa6
commit d38afa6f48

View File

@ -304,10 +304,13 @@ virtio_vq_init(struct virtio_base *base, uint32_t pfn)
/* ... and the last page(s) are the used ring. */
vq->used = (struct vring_used *)vb;
/* Mark queue as allocated, and start at 0 when we use it. */
vq->flags = VQ_ALLOC;
/* Start at 0 when we use it. */
vq->last_avail = 0;
vq->save_used = 0;
/* Mark queue as allocated after initialization is complete. */
mb();
vq->flags = VQ_ALLOC;
}
/*
@ -346,13 +349,16 @@ virtio_vq_enable(struct virtio_base *base)
vb = paddr_guest2host(base->dev->vmctx, phys, size);
vq->used = (struct vring_used *)vb;
/* Mark queue as allocated, and start at 0 when we use it. */
vq->flags = VQ_ALLOC;
/* Start at 0 when we use it. */
vq->last_avail = 0;
vq->save_used = 0;
/* Mark queue as enabled. */
vq->enabled = true;
/* Mark queue as allocated after initialization is complete. */
mb();
vq->flags = VQ_ALLOC;
}
/*