diff options
author | br <br@FreeBSD.org> | 2014-12-12 11:19:10 +0000 |
---|---|---|
committer | br <br@FreeBSD.org> | 2014-12-12 11:19:10 +0000 |
commit | 590ae6af07e83cf471e5bc55da638bc84b8cb098 (patch) | |
tree | 5644298e361fe0b9d832fde5120cede6aaf55b93 /sys/dev | |
parent | 13be1bdb02b85b8e4a3fc8571e527ab6a3db36f7 (diff) | |
download | FreeBSD-src-590ae6af07e83cf471e5bc55da638bc84b8cb098.zip FreeBSD-src-590ae6af07e83cf471e5bc55da638bc84b8cb098.tar.gz |
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
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/beri/virtio/virtio_mmio_platform.c | 10 | ||||
-rw-r--r-- | sys/dev/virtio/mmio/virtio_mmio.c | 13 | ||||
-rw-r--r-- | sys/dev/virtio/mmio/virtio_mmio_if.m | 7 | ||||
-rw-r--r-- | sys/dev/virtio/virtio_bus_if.m | 5 | ||||
-rw-r--r-- | sys/dev/virtio/virtqueue.c | 5 |
5 files changed, 39 insertions, 1 deletions
diff --git a/sys/dev/beri/virtio/virtio_mmio_platform.c b/sys/dev/beri/virtio/virtio_mmio_platform.c index 0c58747d..86244ba 100644 --- a/sys/dev/beri/virtio/virtio_mmio_platform.c +++ b/sys/dev/beri/virtio/virtio_mmio_platform.c @@ -234,12 +234,22 @@ platform_setup_intr(device_t dev, device_t mmio_dev, 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 }; diff --git a/sys/dev/virtio/mmio/virtio_mmio.c b/sys/dev/virtio/mmio/virtio_mmio.c index 5c6a0e1..c41eafc 100644 --- a/sys/dev/virtio/mmio/virtio_mmio.c +++ b/sys/dev/virtio/mmio/virtio_mmio.c @@ -114,6 +114,7 @@ static int vtmmio_alloc_virtqueues(device_t, int, int, 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) { diff --git a/sys/dev/virtio/mmio/virtio_mmio_if.m b/sys/dev/virtio/mmio/virtio_mmio_if.m index 8514c30..499c619 100644 --- a/sys/dev/virtio/mmio/virtio_mmio_if.m +++ b/sys/dev/virtio/mmio/virtio_mmio_if.m @@ -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 { diff --git a/sys/dev/virtio/virtio_bus_if.m b/sys/dev/virtio/virtio_bus_if.m index 74341ff..cbf6069 100644 --- a/sys/dev/virtio/virtio_bus_if.m +++ b/sys/dev/virtio/virtio_bus_if.m @@ -87,3 +87,8 @@ METHOD void write_device_config { void *src; int len; }; + +METHOD void poll { + device_t dev; +}; + diff --git a/sys/dev/virtio/virtqueue.c b/sys/dev/virtio/virtqueue.c index 9401608..e25d39e 100644 --- a/sys/dev/virtio/virtqueue.c +++ b/sys/dev/virtio/virtqueue.c @@ -567,8 +567,11 @@ virtqueue_poll(struct virtqueue *vq, uint32_t *len) { 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); } |