Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a6596127 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin
Browse files

virtio_ring: update weak barriers to use virt_xxx



virtio ring uses smp_wmb on SMP and wmb on !SMP,
the reason for the later being that it might be
talking to another kernel on the same SMP machine.

This is exactly what virt_xxx barriers do,
so switch to these instead of homegrown ifdef hacks.

Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Alexander Duyck <alexander.duyck@gmail.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
parent d307fb16
Loading
Loading
Loading
Loading
+4 −21
Original line number Original line Diff line number Diff line
@@ -12,7 +12,7 @@
 * anyone care?
 * anyone care?
 *
 *
 * For virtio_pci on SMP, we don't need to order with respect to MMIO
 * For virtio_pci on SMP, we don't need to order with respect to MMIO
 * accesses through relaxed memory I/O windows, so smp_mb() et al are
 * accesses through relaxed memory I/O windows, so virt_mb() et al are
 * sufficient.
 * sufficient.
 *
 *
 * For using virtio to talk to real devices (eg. other heterogeneous
 * For using virtio to talk to real devices (eg. other heterogeneous
@@ -21,11 +21,10 @@
 * actually quite cheap.
 * actually quite cheap.
 */
 */


#ifdef CONFIG_SMP
static inline void virtio_mb(bool weak_barriers)
static inline void virtio_mb(bool weak_barriers)
{
{
	if (weak_barriers)
	if (weak_barriers)
		smp_mb();
		virt_mb();
	else
	else
		mb();
		mb();
}
}
@@ -33,7 +32,7 @@ static inline void virtio_mb(bool weak_barriers)
static inline void virtio_rmb(bool weak_barriers)
static inline void virtio_rmb(bool weak_barriers)
{
{
	if (weak_barriers)
	if (weak_barriers)
		smp_rmb();
		virt_rmb();
	else
	else
		rmb();
		rmb();
}
}
@@ -41,26 +40,10 @@ static inline void virtio_rmb(bool weak_barriers)
static inline void virtio_wmb(bool weak_barriers)
static inline void virtio_wmb(bool weak_barriers)
{
{
	if (weak_barriers)
	if (weak_barriers)
		smp_wmb();
		virt_wmb();
	else
	else
		wmb();
		wmb();
}
}
#else
static inline void virtio_mb(bool weak_barriers)
{
	mb();
}

static inline void virtio_rmb(bool weak_barriers)
{
	rmb();
}

static inline void virtio_wmb(bool weak_barriers)
{
	wmb();
}
#endif


struct virtio_device;
struct virtio_device;
struct virtqueue;
struct virtqueue;