From owner-svn-src-projects@FreeBSD.ORG Sun Feb 3 23:32:56 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E94A3BF; Sun, 3 Feb 2013 23:32:56 +0000 (UTC) (envelope-from bryanv@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id C43F5F11; Sun, 3 Feb 2013 23:32:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r13NWuEn087575; Sun, 3 Feb 2013 23:32:56 GMT (envelope-from bryanv@svn.freebsd.org) Received: (from bryanv@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r13NWue2087574; Sun, 3 Feb 2013 23:32:56 GMT (envelope-from bryanv@svn.freebsd.org) Message-Id: <201302032332.r13NWue2087574@svn.freebsd.org> From: Bryan Venteicher Date: Sun, 3 Feb 2013 23:32:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r246304 - projects/virtio/sys/dev/virtio/pci X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Feb 2013 23:32:57 -0000 Author: bryanv Date: Sun Feb 3 23:32:56 2013 New Revision: 246304 URL: http://svnweb.freebsd.org/changeset/base/246304 Log: virtio_pci: Clean up after failed virtqueue alloc attempt Useful if the the driver wants to retry with fewer queues. Approved by: grehan (implicit) Modified: projects/virtio/sys/dev/virtio/pci/virtio_pci.c Modified: projects/virtio/sys/dev/virtio/pci/virtio_pci.c ============================================================================== --- projects/virtio/sys/dev/virtio/pci/virtio_pci.c Sun Feb 3 23:31:40 2013 (r246303) +++ projects/virtio/sys/dev/virtio/pci/virtio_pci.c Sun Feb 3 23:32:56 2013 (r246304) @@ -518,6 +518,9 @@ vtpci_alloc_virtqueues(device_t dev, int sc->vtpci_nvqs++; } + if (error) + vtpci_free_virtqueues(sc); + return (error); } @@ -1169,10 +1172,13 @@ static void vtpci_free_virtqueues(struct vtpci_softc *sc) { struct vtpci_virtqueue *vqx; - int i; + int idx; - for (i = 0; i < sc->vtpci_nvqs; i++) { - vqx = &sc->vtpci_vqs[i]; + for (idx = 0; idx < sc->vtpci_nvqs; idx++) { + vqx = &sc->vtpci_vqs[idx]; + + vtpci_select_virtqueue(sc, idx); + vtpci_write_config_4(sc, VIRTIO_PCI_QUEUE_PFN, 0); virtqueue_free(vqx->vtv_vq); vqx->vtv_vq = NULL;