Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Dec 2014 11:19:11 +0000 (UTC)
From:      Ruslan Bukin <br@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r275728 - in head/sys/dev: beri/virtio virtio virtio/mmio
Message-ID:  <201412121119.sBCBJBVu089985@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: br
Date: Fri Dec 12 11:19:10 2014
New Revision: 275728
URL: https://svnweb.freebsd.org/changeset/base/275728

Log:
  Add virtio bus 'poll' method allowing us to inform backend we are
  going to poll virtqueue.
  
  Use on BERI soft-core to invalidate cpu caches.
  
  Reviewed by:	bryanv
  Sponsored by:	DARPA, AFRL

Modified:
  head/sys/dev/beri/virtio/virtio_mmio_platform.c
  head/sys/dev/virtio/mmio/virtio_mmio.c
  head/sys/dev/virtio/mmio/virtio_mmio_if.m
  head/sys/dev/virtio/virtio_bus_if.m
  head/sys/dev/virtio/virtqueue.c

Modified: head/sys/dev/beri/virtio/virtio_mmio_platform.c
==============================================================================
--- head/sys/dev/beri/virtio/virtio_mmio_platform.c	Fri Dec 12 09:37:18 2014	(r275727)
+++ head/sys/dev/beri/virtio/virtio_mmio_platform.c	Fri Dec 12 11:19:10 2014	(r275728)
@@ -234,12 +234,22 @@ platform_setup_intr(device_t dev, device
 	return (0);
 }
 
+static int
+platform_poll(device_t dev)
+{
+
+	mips_dcache_wbinv_all();
+
+	return (0);
+}
+
 static device_method_t virtio_mmio_platform_methods[] = {
 	DEVMETHOD(device_probe,		virtio_mmio_platform_probe),
 	DEVMETHOD(device_attach,	virtio_mmio_platform_attach),
 
 	/* virtio_mmio_if.h */
 	DEVMETHOD(virtio_mmio_note,		platform_note),
+	DEVMETHOD(virtio_mmio_poll,		platform_poll),
 	DEVMETHOD(virtio_mmio_setup_intr,	platform_setup_intr),
 	DEVMETHOD_END
 };

Modified: head/sys/dev/virtio/mmio/virtio_mmio.c
==============================================================================
--- head/sys/dev/virtio/mmio/virtio_mmio.c	Fri Dec 12 09:37:18 2014	(r275727)
+++ head/sys/dev/virtio/mmio/virtio_mmio.c	Fri Dec 12 11:19:10 2014	(r275728)
@@ -114,6 +114,7 @@ static int	vtmmio_alloc_virtqueues(devic
 		    struct vq_alloc_info *);
 static int	vtmmio_setup_intr(device_t, enum intr_type);
 static void	vtmmio_stop(device_t);
+static void	vtmmio_poll(device_t);
 static int	vtmmio_reinit(device_t, uint64_t);
 static void	vtmmio_reinit_complete(device_t);
 static void	vtmmio_notify_virtqueue(device_t, uint16_t);
@@ -182,6 +183,7 @@ static device_method_t vtmmio_methods[] 
 	DEVMETHOD(virtio_bus_alloc_virtqueues,	  vtmmio_alloc_virtqueues),
 	DEVMETHOD(virtio_bus_setup_intr,	  vtmmio_setup_intr),
 	DEVMETHOD(virtio_bus_stop,		  vtmmio_stop),
+	DEVMETHOD(virtio_bus_poll,		  vtmmio_poll),
 	DEVMETHOD(virtio_bus_reinit,		  vtmmio_reinit),
 	DEVMETHOD(virtio_bus_reinit_complete,	  vtmmio_reinit_complete),
 	DEVMETHOD(virtio_bus_notify_vq,		  vtmmio_notify_virtqueue),
@@ -550,6 +552,17 @@ vtmmio_stop(device_t dev)
 	vtmmio_reset(device_get_softc(dev));
 }
 
+static void
+vtmmio_poll(device_t dev)
+{
+	struct vtmmio_softc *sc;
+
+	sc = device_get_softc(dev);
+
+	if (sc->platform != NULL)
+		VIRTIO_MMIO_POLL(sc->platform);
+}
+
 static int
 vtmmio_reinit(device_t dev, uint64_t features)
 {

Modified: head/sys/dev/virtio/mmio/virtio_mmio_if.m
==============================================================================
--- head/sys/dev/virtio/mmio/virtio_mmio_if.m	Fri Dec 12 09:37:18 2014	(r275727)
+++ head/sys/dev/virtio/mmio/virtio_mmio_if.m	Fri Dec 12 11:19:10 2014	(r275728)
@@ -67,6 +67,13 @@ METHOD int note {
 } DEFAULT virtio_mmio_note;
 
 #
+# Inform backend we are going to poll virtqueue.
+#
+METHOD int poll {
+	device_t	dev;
+};
+
+#
 # Setup backend-specific interrupts.
 #
 METHOD int setup_intr {

Modified: head/sys/dev/virtio/virtio_bus_if.m
==============================================================================
--- head/sys/dev/virtio/virtio_bus_if.m	Fri Dec 12 09:37:18 2014	(r275727)
+++ head/sys/dev/virtio/virtio_bus_if.m	Fri Dec 12 11:19:10 2014	(r275728)
@@ -87,3 +87,8 @@ METHOD void write_device_config {
 	void		*src;
 	int		len;
 };
+
+METHOD void poll {
+	device_t	dev;
+};
+

Modified: head/sys/dev/virtio/virtqueue.c
==============================================================================
--- head/sys/dev/virtio/virtqueue.c	Fri Dec 12 09:37:18 2014	(r275727)
+++ head/sys/dev/virtio/virtqueue.c	Fri Dec 12 11:19:10 2014	(r275728)
@@ -567,8 +567,11 @@ virtqueue_poll(struct virtqueue *vq, uin
 {
 	void *cookie;
 
-	while ((cookie = virtqueue_dequeue(vq, len)) == NULL)
+	VIRTIO_BUS_POLL(vq->vq_dev);
+	while ((cookie = virtqueue_dequeue(vq, len)) == NULL) {
 		cpu_spinwait();
+		VIRTIO_BUS_POLL(vq->vq_dev);
+	}
 
 	return (cookie);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201412121119.sBCBJBVu089985>