Attributes 'weak_barriers' and 'notify' are moved from struct vring_virtqueue to struct virtqueue. Signed-off-by: Sjur Brændeland <sjur.brandeland@xxxxxxxxxxxxxx> --- drivers/virtio/virtio_ring.c | 20 +++++++------------- include/linux/virtio.h | 4 ++++ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index ffd7e7d..6aa76b4 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -31,11 +31,11 @@ * barriers, because mandatory barriers control MMIO effects on accesses * through relaxed memory I/O windows (which virtio-pci does not use). */ #define virtio_mb(vq) \ - do { if ((vq)->weak_barriers) smp_mb(); else mb(); } while(0) + do { if ((vq)->vq.weak_barriers) smp_mb(); else mb(); } while (0) #define virtio_rmb(vq) \ - do { if ((vq)->weak_barriers) smp_rmb(); else rmb(); } while(0) + do { if ((vq)->vq.weak_barriers) smp_rmb(); else rmb(); } while (0) #define virtio_wmb(vq) \ - do { if ((vq)->weak_barriers) smp_wmb(); else wmb(); } while(0) + do { if ((vq)->vq.weak_barriers) smp_wmb(); else wmb(); } while (0) #else /* We must force memory ordering even if guest is UP since host could be * running on another CPU, but SMP barriers are defined to barrier() in that @@ -81,9 +81,6 @@ struct vring_virtqueue /* Actual memory layout for this queue */ struct vring vring; - /* Can we use weak barriers? */ - bool weak_barriers; - /* Other side has made a mess, don't try any more. */ bool broken; @@ -101,9 +98,6 @@ struct vring_virtqueue /* Last used index we've seen. */ u16 last_used_idx; - /* How to notify other side. FIXME: commonalize hcalls! */ - void (*notify)(struct virtqueue *vq); - #ifdef DEBUG /* They're supposed to lock for us. */ unsigned int in_use; @@ -236,7 +230,7 @@ int virtqueue_add_buf(struct virtqueue *_vq, * there are outgoing parts to the buffer. Presumably the * host should service the ring ASAP. */ if (out) - vq->notify(&vq->vq); + vq->vq.notify(&vq->vq); END_USE(vq); return -ENOSPC; } @@ -348,7 +342,7 @@ void virtqueue_notify(struct virtqueue *_vq) struct vring_virtqueue *vq = to_vvq(_vq); /* Prod other side to tell it about changes. */ - vq->notify(_vq); + vq->vq.notify(_vq); } EXPORT_SYMBOL_GPL(virtqueue_notify); @@ -647,8 +641,8 @@ struct virtqueue *vring_new_virtqueue(unsigned int index, vq->vq.name = name; vq->vq.num_free = num; vq->vq.index = index; - vq->notify = notify; - vq->weak_barriers = weak_barriers; + vq->vq.notify = notify; + vq->vq.weak_barriers = weak_barriers; vq->broken = false; vq->last_used_idx = 0; vq->num_added = 0; diff --git a/include/linux/virtio.h b/include/linux/virtio.h index 25fa1a6..f513ba8 100644 --- a/include/linux/virtio.h +++ b/include/linux/virtio.h @@ -13,11 +13,13 @@ * virtqueue - a queue to register buffers for sending or receiving. * @list: the chain of virtqueues for this device * @callback: the function to call when buffers are consumed (can be NULL). + * @notify: the function to notify the other side (can be NULL) * @name: the name of this virtqueue (mainly for debugging) * @vdev: the virtio device this queue was created for. * @priv: a pointer for the virtqueue implementation to use. * @index: the zero-based ordinal number for this queue. * @num_free: number of elements we expect to be able to fit. + * @weak_barriers: indicate if we can use weak memory barriers. * * A note on @num_free: with indirect buffers, each buffer needs one * element in the queue, otherwise a buffer will need one element per @@ -26,11 +28,13 @@ struct virtqueue { struct list_head list; void (*callback)(struct virtqueue *vq); + void (*notify)(struct virtqueue *vq); const char *name; struct virtio_device *vdev; unsigned int index; unsigned int num_free; void *priv; + bool weak_barriers; }; int virtqueue_add_buf(struct virtqueue *vq, -- 1.7.5.4 _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/virtualization