svn commit: r246304 - projects/virtio/sys/dev/virtio/pci
Bryan Venteicher
bryanv at FreeBSD.org
Sun Feb 3 23:32:57 UTC 2013
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;
More information about the svn-src-projects
mailing list