Move macros from virtio_ring.c to virtio_ring.h so that they can be used outside the file. Signed-off-by: Sjur Brændeland <sjur.brandeland@xxxxxxxxxxxxxx> --- drivers/virtio/virtio_ring.c | 21 --------------------- include/linux/virtio_ring.h | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 6aa76b4..ead47d7 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -24,27 +24,6 @@ #include <linux/module.h> #include <linux/hrtimer.h> -/* virtio guest is communicating with a virtual "device" that actually runs on - * a host processor. Memory barriers are used to control SMP effects. */ -#ifdef CONFIG_SMP -/* Where possible, use SMP barriers which are more lightweight than mandatory - * 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)->vq.weak_barriers) smp_mb(); else mb(); } while (0) -#define virtio_rmb(vq) \ - do { if ((vq)->vq.weak_barriers) smp_rmb(); else rmb(); } while (0) -#define virtio_wmb(vq) \ - 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 - * configuration. So fall back to mandatory barriers instead. */ -#define virtio_mb(vq) mb() -#define virtio_rmb(vq) rmb() -#define virtio_wmb(vq) wmb() -#endif - #ifdef DEBUG /* For development, we want to crash whenever the ring is screwed. */ #define BAD_RING(_vq, fmt, args...) \ diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h index 6c9b871..1a4023b 100644 --- a/include/linux/virtio_ring.h +++ b/include/linux/virtio_ring.h @@ -42,4 +42,24 @@ int vring_avail_desc_user(struct vring_host *vh); struct vring_used_elem *vring_add_used_user(struct vring_host *vh, unsigned int head, int len); +/* virtio guest is communicating with a virtual "device" that actually runs on + * a host processor. Memory barriers are used to control SMP effects. */ +#ifdef CONFIG_SMP +/* Where possible, use SMP barriers which are more lightweight than mandatory + * 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)->vq.weak_barriers) smp_mb(); else mb(); } while (0) +#define virtio_rmb(vq) \ + do { if ((vq)->vq.weak_barriers) smp_rmb(); else rmb(); } while (0) +#define virtio_wmb(vq) \ + 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 + * configuration. So fall back to mandatory barriers instead. */ +#define virtio_mb(vq) mb() +#define virtio_rmb(vq) rmb() +#define virtio_wmb(vq) wmb() +#endif #endif /* _LINUX_VIRTIO_RING_H */ -- 1.7.5.4 _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/virtualization