Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Feb 2013 23:32:56 +0000 (UTC)
From:      Bryan Venteicher <bryanv@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r246304 - projects/virtio/sys/dev/virtio/pci
Message-ID:  <201302032332.r13NWue2087574@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;



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