Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F109659287
D20581.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D20581.diff
View Options
Index: head/usr.sbin/bhyve/pci_virtio_console.c
===================================================================
--- head/usr.sbin/bhyve/pci_virtio_console.c
+++ head/usr.sbin/bhyve/pci_virtio_console.c
@@ -607,7 +607,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: head/usr.sbin/bhyve/pci_virtio_net.c
===================================================================
--- head/usr.sbin/bhyve/pci_virtio_net.c
+++ head/usr.sbin/bhyve/pci_virtio_net.c
@@ -39,7 +39,6 @@
#include <sys/select.h>
#include <sys/uio.h>
#include <sys/ioctl.h>
-#include <machine/atomic.h>
#include <net/ethernet.h>
#ifndef NETMAP_WITH_LIBS
#define NETMAP_WITH_LIBS
@@ -585,7 +584,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);
}
}
@@ -631,7 +630,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);
@@ -660,8 +659,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;
@@ -669,7 +667,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: head/usr.sbin/bhyve/pci_virtio_scsi.c
===================================================================
--- head/usr.sbin/bhyve/pci_virtio_scsi.c
+++ head/usr.sbin/bhyve/pci_virtio_scsi.c
@@ -581,7 +581,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: head/usr.sbin/bhyve/virtio.h
===================================================================
--- head/usr.sbin/bhyve/virtio.h
+++ head/usr.sbin/bhyve/virtio.h
@@ -31,6 +31,8 @@
#ifndef _VIRTIO_H_
#define _VIRTIO_H_
+#include <machine/atomic.h>
+
/*
* These are derived from several virtio specifications.
*
@@ -445,6 +447,26 @@
pci_lintr_assert(vs->vs_pi);
VS_UNLOCK(vs);
}
+}
+
+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;
Index: head/usr.sbin/bhyve/virtio.c
===================================================================
--- head/usr.sbin/bhyve/virtio.c
+++ head/usr.sbin/bhyve/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
Details
Attached
Mime Type
text/plain
Expires
Sun, Feb 9, 1:24 AM (3 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16539182
Default Alt Text
D20581.diff (3 KB)
Attached To
Mode
D20581: bhyve: virtio: introduce vq_kick_enable() and vq_kick_disable()
Attached
Detach File
Event Timeline
Log In to Comment