From ac4b6bcd1734f55d1947f3bab9f860b87d0d2012 Mon Sep 17 00:00:00 2001 From: Bryan Venteicher Date: Fri, 14 Dec 2012 05:27:56 +0000 Subject: [PATCH] virtio: Start taskqueues threads after attach cannot fail If virtio_setup_intr() failed during boot, we would hang in taskqueue_free() -> taskqueue_terminate() for all the taskq threads to terminate. This will never happen since the scheduler is not running by this point. Reported by: neel, grehan Approved by: grehan (mentor) --- sys/dev/virtio/block/virtio_blk.c | 5 +++-- sys/dev/virtio/network/if_vtnet.c | 7 +++---- sys/dev/virtio/scsi/virtio_scsi.c | 9 +++------ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/sys/dev/virtio/block/virtio_blk.c b/sys/dev/virtio/block/virtio_blk.c index d35421a7659..cb628f659a4 100644 --- a/sys/dev/virtio/block/virtio_blk.c +++ b/sys/dev/virtio/block/virtio_blk.c @@ -338,8 +338,6 @@ vtblk_attach(device_t dev) device_printf(dev, "cannot allocate taskqueue\n"); goto fail; } - taskqueue_start_threads(&sc->vtblk_tq, 1, PI_DISK, "%s taskq", - device_get_nameunit(dev)); error = virtio_setup_intr(dev, INTR_TYPE_BIO | INTR_ENTROPY); if (error) { @@ -347,6 +345,9 @@ vtblk_attach(device_t dev) goto fail; } + taskqueue_start_threads(&sc->vtblk_tq, 1, PI_DISK, "%s taskq", + device_get_nameunit(dev)); + vtblk_create_disk(sc); virtqueue_enable_intr(sc->vtblk_vq); diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c index b2ebbf07716..ffc349afcbd 100644 --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -439,18 +439,17 @@ vtnet_attach(device_t dev) ether_ifdetach(ifp); goto fail; } - taskqueue_start_threads(&sc->vtnet_tq, 1, PI_NET, "%s taskq", - device_get_nameunit(dev)); error = virtio_setup_intr(dev, INTR_TYPE_NET); if (error) { device_printf(dev, "cannot setup virtqueue interrupts\n"); - taskqueue_free(sc->vtnet_tq); - sc->vtnet_tq = NULL; ether_ifdetach(ifp); goto fail; } + taskqueue_start_threads(&sc->vtnet_tq, 1, PI_NET, "%s taskq", + device_get_nameunit(dev)); + /* * Device defaults to promiscuous mode for backwards * compatibility. Turn it off if possible. diff --git a/sys/dev/virtio/scsi/virtio_scsi.c b/sys/dev/virtio/scsi/virtio_scsi.c index 168e9b86adb..86684ba9779 100644 --- a/sys/dev/virtio/scsi/virtio_scsi.c +++ b/sys/dev/virtio/scsi/virtio_scsi.c @@ -347,12 +347,6 @@ vtscsi_attach(device_t dev) device_printf(dev, "cannot allocate taskqueue\n"); goto fail; } - error = taskqueue_start_threads(&sc->vtscsi_tq, 1, PI_DISK, "%s taskq", - device_get_nameunit(dev)); - if (error) { - device_printf(dev, "cannot start taskqueue threads\n"); - goto fail; - } error = virtio_setup_intr(dev, INTR_TYPE_CAM); if (error) { @@ -360,6 +354,9 @@ vtscsi_attach(device_t dev) goto fail; } + taskqueue_start_threads(&sc->vtscsi_tq, 1, PI_DISK, "%s taskq", + device_get_nameunit(dev)); + vtscsi_enable_vqs_intr(sc); /*