Page MenuHomeFreeBSD

D20581.1791100272.diff
No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None

D20581.1791100272.diff

Index: pci_virtio_block.c
===================================================================
--- pci_virtio_block.c
+++ pci_virtio_block.c
@@ -39,6 +39,8 @@
#include <sys/ioctl.h>
#include <sys/disk.h>
+#include <machine/atomic.h>
+
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
Index: pci_virtio_console.c
===================================================================
--- pci_virtio_console.c
+++ pci_virtio_console.c
@@ -43,6 +43,8 @@
#include <sys/socket.h>
#include <sys/un.h>
+#include <machine/atomic.h>
+
#ifndef WITHOUT_CAPSICUM
#include <capsicum_helpers.h>
#endif
@@ -607,7 +609,7 @@
if (!port->vsp_rx_ready) {
port->vsp_rx_ready = 1;
- vq->vq_used->vu_flags |= VRING_USED_F_NO_NOTIFY;
+ vq_kick_disable(vq);
}
}
Index: pci_virtio_net.c
===================================================================
--- pci_virtio_net.c
+++ pci_virtio_net.c
@@ -611,7 +611,7 @@
*/
if (sc->vsc_rx_ready == 0) {
sc->vsc_rx_ready = 1;
- vq->vq_used->vu_flags |= VRING_USED_F_NO_NOTIFY;
+ vq_kick_disable(vq);
}
}
@@ -657,7 +657,7 @@
/* Signal the tx thread for processing */
pthread_mutex_lock(&sc->tx_mtx);
- vq->vq_used->vu_flags |= VRING_USED_F_NO_NOTIFY;
+ vq_kick_disable(vq);
if (sc->tx_in_progress == 0)
pthread_cond_signal(&sc->tx_cond);
pthread_mutex_unlock(&sc->tx_mtx);
@@ -686,8 +686,7 @@
for (;;) {
/* note - tx mutex is locked here */
while (sc->resetting || !vq_has_descs(vq)) {
- vq->vq_used->vu_flags &= ~VRING_USED_F_NO_NOTIFY;
- mb();
+ vq_kick_enable(vq);
if (!sc->resetting && vq_has_descs(vq))
break;
@@ -695,7 +694,7 @@
error = pthread_cond_wait(&sc->tx_cond, &sc->tx_mtx);
assert(error == 0);
}
- vq->vq_used->vu_flags |= VRING_USED_F_NO_NOTIFY;
+ vq_kick_disable(vq);
sc->tx_in_progress = 1;
pthread_mutex_unlock(&sc->tx_mtx);
Index: pci_virtio_rnd.c
===================================================================
--- pci_virtio_rnd.c
+++ pci_virtio_rnd.c
@@ -43,6 +43,8 @@
#include <sys/linker_set.h>
#include <sys/uio.h>
+#include <machine/atomic.h>
+
#ifndef WITHOUT_CAPSICUM
#include <capsicum_helpers.h>
#endif
Index: pci_virtio_scsi.c
===================================================================
--- pci_virtio_scsi.c
+++ pci_virtio_scsi.c
@@ -39,6 +39,8 @@
#include <sys/queue.h>
#include <sys/sbuf.h>
+#include <machine/atomic.h>
+
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
@@ -581,7 +583,7 @@
pci_vtscsi_eventq_notify(void *vsc, struct vqueue_info *vq)
{
- vq->vq_used->vu_flags |= VRING_USED_F_NO_NOTIFY;
+ vq_kick_disable(vq);
}
static void
Index: virtio.h
===================================================================
--- virtio.h
+++ virtio.h
@@ -447,6 +447,26 @@
}
}
+static inline void
+vq_kick_enable(struct vqueue_info *vq)
+{
+
+ vq->vq_used->vu_flags &= ~VRING_USED_F_NO_NOTIFY;
+ /*
+ * Full memory barrier to make sure the store to vu_flags
+ * happens before the load from va_idx, which results from
+ * a subsequent call to vq_has_descs().
+ */
+ atomic_thread_fence_seq_cst();
+}
+
+static inline void
+vq_kick_disable(struct vqueue_info *vq)
+{
+
+ vq->vq_used->vu_flags |= VRING_USED_F_NO_NOTIFY;
+}
+
struct iovec;
void vi_softc_linkup(struct virtio_softc *vs, struct virtio_consts *vc,
void *dev_softc, struct pci_devinst *pi,
Index: virtio.c
===================================================================
--- virtio.c
+++ virtio.c
@@ -428,7 +428,8 @@
/*
* Ensure the used descriptor is visible before updating the index.
- * This is necessary on ISAs with memory ordering less strict than x86.
+ * This is necessary on ISAs with memory ordering less strict than x86
+ * (and even on x86 to act as a compiler barrier).
*/
atomic_thread_fence_rel();
vuh->vu_idx = uidx;

File Metadata

Mime Type
text/plain
Expires
Sun, Oct 4, 7:51 AM (17 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30151453
Default Alt Text
D20581.1791100272.diff (3 KB)

Event Timeline