mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-05 10:06:48 +07:00
9e1a27ea42
This change makes it so that instead of using smp_wmb/rmb which varies depending on the kernel configuration we can can use dma_wmb/rmb which for most architectures should be equal to or slightly more strict than smp_wmb/rmb. The advantage to this is that these barriers are available to uniprocessor builds as well so the performance should improve under such a configuration. Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
68 lines
1.7 KiB
C
68 lines
1.7 KiB
C
#ifndef _LINUX_VIRTIO_RING_H
|
|
#define _LINUX_VIRTIO_RING_H
|
|
|
|
#include <asm/barrier.h>
|
|
#include <linux/irqreturn.h>
|
|
#include <uapi/linux/virtio_ring.h>
|
|
|
|
/*
|
|
* Barriers in virtio are tricky. Non-SMP virtio guests can't assume
|
|
* they're not on an SMP host system, so they need to assume real
|
|
* barriers. Non-SMP virtio hosts could skip the barriers, but does
|
|
* anyone care?
|
|
*
|
|
* 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
|
|
* sufficient.
|
|
*
|
|
* For using virtio to talk to real devices (eg. other heterogeneous
|
|
* CPUs) we do need real barriers. In theory, we could be using both
|
|
* kinds of virtio, so it's a runtime decision, and the branch is
|
|
* actually quite cheap.
|
|
*/
|
|
|
|
static inline void virtio_mb(bool weak_barriers)
|
|
{
|
|
#ifdef CONFIG_SMP
|
|
if (weak_barriers)
|
|
smp_mb();
|
|
else
|
|
#endif
|
|
mb();
|
|
}
|
|
|
|
static inline void virtio_rmb(bool weak_barriers)
|
|
{
|
|
if (weak_barriers)
|
|
dma_rmb();
|
|
else
|
|
rmb();
|
|
}
|
|
|
|
static inline void virtio_wmb(bool weak_barriers)
|
|
{
|
|
if (weak_barriers)
|
|
dma_wmb();
|
|
else
|
|
wmb();
|
|
}
|
|
|
|
struct virtio_device;
|
|
struct virtqueue;
|
|
|
|
struct virtqueue *vring_new_virtqueue(unsigned int index,
|
|
unsigned int num,
|
|
unsigned int vring_align,
|
|
struct virtio_device *vdev,
|
|
bool weak_barriers,
|
|
void *pages,
|
|
bool (*notify)(struct virtqueue *vq),
|
|
void (*callback)(struct virtqueue *vq),
|
|
const char *name);
|
|
void vring_del_virtqueue(struct virtqueue *vq);
|
|
/* Filter out transport-specific feature bits. */
|
|
void vring_transport_features(struct virtio_device *vdev);
|
|
|
|
irqreturn_t vring_interrupt(int irq, void *_vq);
|
|
#endif /* _LINUX_VIRTIO_RING_H */
|