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
This commit is contained in:
Ruslan Bukin 2014-12-12 11:19:10 +00:00
parent fe21241ee0
commit 156b97fa1f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=275728
5 changed files with 39 additions and 1 deletions

View File

@ -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
};

View File

@ -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)
{

View File

@ -66,6 +66,13 @@ METHOD int note {
int val;
} DEFAULT virtio_mmio_note;
#
# Inform backend we are going to poll virtqueue.
#
METHOD int poll {
device_t dev;
};
#
# Setup backend-specific interrupts.
#

View File

@ -87,3 +87,8 @@ METHOD void write_device_config {
void *src;
int len;
};
METHOD void poll {
device_t dev;
};

View File

@ -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);
}