From owner-svn-src-all@FreeBSD.ORG Fri Dec 12 11:19:12 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DDBB62DD; Fri, 12 Dec 2014 11:19:12 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C977B8F5; Fri, 12 Dec 2014 11:19:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBCBJCfB089996; Fri, 12 Dec 2014 11:19:12 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBCBJBVu089985; Fri, 12 Dec 2014 11:19:11 GMT (envelope-from br@FreeBSD.org) Message-Id: <201412121119.sBCBJBVu089985@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Fri, 12 Dec 2014 11:19:11 +0000 (UTC) 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 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Dec 2014 11:19:13 -0000 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); }