summaryrefslogtreecommitdiffstats
path: root/include/linux/virtio_ring.h
diff options
context:
space:
mode:
authorMichael S. Tsirkin2015-12-17 11:20:39 +0100
committerMichael S. Tsirkin2016-01-12 19:47:02 +0100
commit788e5b3a5da24cc8d93ce2f7c6508181cd7d7fb6 (patch)
tree7e54e74c3f7373a04780ad14cb157089c76abeb2 /include/linux/virtio_ring.h
parentsh: move xchg_cmpxchg to a header by itself (diff)
downloadkernel-qcow2-linux-788e5b3a5da24cc8d93ce2f7c6508181cd7d7fb6.tar.gz
kernel-qcow2-linux-788e5b3a5da24cc8d93ce2f7c6508181cd7d7fb6.tar.xz
kernel-qcow2-linux-788e5b3a5da24cc8d93ce2f7c6508181cd7d7fb6.zip
virtio_ring: use virt_store_mb
We need a full barrier after writing out event index, using virt_store_mb there seems better than open-coding. As usual, we need a wrapper to account for strong barriers. It's tempting to use this in vhost as well, for that, we'll need a variant of smp_store_mb that works on __user pointers. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Diffstat (limited to 'include/linux/virtio_ring.h')
-rw-r--r--include/linux/virtio_ring.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
index f3fa55bdd6ce..a156e2b6ccfe 100644
--- a/include/linux/virtio_ring.h
+++ b/include/linux/virtio_ring.h
@@ -45,6 +45,17 @@ static inline void virtio_wmb(bool weak_barriers)
wmb();
}
+static inline void virtio_store_mb(bool weak_barriers,
+ __virtio16 *p, __virtio16 v)
+{
+ if (weak_barriers) {
+ virt_store_mb(*p, v);
+ } else {
+ WRITE_ONCE(*p, v);
+ mb();
+ }
+}
+
struct virtio_device;
struct virtqueue;