--- /usr/src/sys/dev/ata/ata-all.h	Wed Oct  4 07:21:40 2006
+++ ata-all.h	Sat Dec  2 15:00:11 2006
@@ -344,7 +344,8 @@
     u_int32_t                   donecount;      /* bytes transferred */
     int                         result;         /* result error code */
     void                        (*callback)(struct ata_request *request);
-    struct sema                 done;           /* request done sema */
+    struct mtx			done_mtx;	/* request done lock */
+    struct cv			done_cv;	/* request done cv */
     int                         retries;        /* retry count */
     int                         timeout;        /* timeout for this cmd */
     struct callout              callout;        /* callout management */
--- /usr/src/sys/dev/ata/ata-card.c	Wed Oct  4 07:21:40 2006
+++ ata-card.c	Sat Dec  2 15:16:02 2006
@@ -33,8 +33,10 @@
 #include <sys/kernel.h>
 #include <sys/module.h>
 #include <sys/bus.h>
+#include <sys/condvar.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
 #include <sys/malloc.h>
-#include <sys/sema.h>
 #include <sys/taskqueue.h>
 #include <vm/uma.h>
 #include <machine/stdarg.h>
--- /usr/src/sys/dev/ata/ata-cbus.c	Wed Oct  4 07:21:40 2006
+++ ata-cbus.c	Sat Dec  2 15:16:32 2006
@@ -33,10 +33,12 @@
 #include <sys/kernel.h>
 #include <sys/ata.h>
 #include <sys/bus.h>
+#include <sys/condvar.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
 #include <sys/malloc.h>
 #include <sys/module.h>
 #include <sys/conf.h>
-#include <sys/sema.h>
 #include <sys/taskqueue.h>
 #include <vm/uma.h>
 #include <machine/resource.h>
--- /usr/src/sys/dev/ata/ata-chipset.c	Sat Oct 28 04:31:57 2006
+++ ata-chipset.c	Sat Dec  2 15:16:52 2006
@@ -33,11 +33,11 @@
 #include <sys/kernel.h>
 #include <sys/ata.h>
 #include <sys/bus.h>
+#include <sys/condvar.h>
 #include <sys/endian.h>
 #include <sys/malloc.h>
 #include <sys/lock.h>
 #include <sys/mutex.h>
-#include <sys/sema.h>
 #include <sys/taskqueue.h>
 #include <vm/uma.h>
 #include <machine/stdarg.h>
--- /usr/src/sys/dev/ata/ata-disk.c	Mon Nov  6 12:42:45 2006
+++ ata-disk.c	Sat Dec  2 15:17:24 2006
@@ -36,11 +36,13 @@
 #include <sys/malloc.h>
 #include <sys/bio.h>
 #include <sys/bus.h>
+#include <sys/condvar.h>
 #include <sys/conf.h>
 #include <sys/disk.h>
 #include <sys/cons.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
 #include <sys/sysctl.h>
-#include <sys/sema.h>
 #include <sys/taskqueue.h>
 #include <vm/uma.h>
 #include <machine/md_var.h>
--- /usr/src/sys/dev/ata/ata-dma.c	Wed Oct  4 07:21:41 2006
+++ ata-dma.c	Sat Dec  2 15:17:52 2006
@@ -30,11 +30,12 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/ata.h>
+#include <sys/condvar.h>
 #include <sys/kernel.h>
 #include <sys/endian.h>
 #include <sys/malloc.h> 
 #include <sys/lock.h>
-#include <sys/sema.h>
+#include <sys/mutex.h>
 #include <sys/taskqueue.h>
 #include <vm/uma.h>
 #include <sys/bus.h>
--- /usr/src/sys/dev/ata/ata-isa.c	Wed Oct  4 07:21:42 2006
+++ ata-isa.c	Sat Dec  2 15:18:27 2006
@@ -34,8 +34,10 @@
 #include <sys/kernel.h>
 #include <sys/module.h>
 #include <sys/bus.h>
+#include <sys/condvar.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
 #include <sys/malloc.h>
-#include <sys/sema.h>
 #include <sys/taskqueue.h>
 #include <vm/uma.h>
 #include <machine/stdarg.h>
--- /usr/src/sys/dev/ata/ata-lowlevel.c	Wed Oct  4 07:21:42 2006
+++ ata-lowlevel.c	Sat Dec  2 15:19:10 2006
@@ -33,10 +33,12 @@
 #include <sys/kernel.h>
 #include <sys/endian.h>
 #include <sys/ata.h>
+#include <sys/condvar.h>
 #include <sys/conf.h>
 #include <sys/ctype.h>
 #include <sys/bus.h>
-#include <sys/sema.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
 #include <sys/taskqueue.h>
 #include <vm/uma.h>
 #include <machine/bus.h>
--- /usr/src/sys/dev/ata/ata-pci.c	Wed Oct  4 07:21:42 2006
+++ ata-pci.c	Sat Dec  2 15:19:40 2006
@@ -34,9 +34,11 @@
 #include <sys/module.h>
 #include <sys/ata.h>
 #include <sys/bus.h>
+#include <sys/condvar.h>
 #include <sys/conf.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
 #include <sys/malloc.h>
-#include <sys/sema.h>
 #include <sys/taskqueue.h>
 #include <vm/uma.h>
 #include <machine/stdarg.h>
--- /usr/src/sys/dev/ata/ata-queue.c	Wed Oct  4 07:21:42 2006
+++ ata-queue.c	Sat Dec  2 15:13:17 2006
@@ -34,8 +34,8 @@
 #include <sys/kernel.h>
 #include <sys/bio.h>
 #include <sys/bus.h>
+#include <sys/condvar.h>
 #include <sys/conf.h>
-#include <sys/sema.h>
 #include <sys/taskqueue.h>
 #include <vm/uma.h>
 #include <machine/bus.h>
@@ -65,8 +65,10 @@
     }
     ch = device_get_softc(request->parent);
     callout_init_mtx(&request->callout, &ch->state_mtx, CALLOUT_RETURNUNLOCKED);
-    if (!request->callback && !(request->flags & ATA_R_REQUEUE))
-	sema_init(&request->done, 0, "ATA request done");
+    if (!request->callback && !(request->flags & ATA_R_REQUEUE)) {
+	mtx_init(&request->done_mtx, "ATA request done lock", NULL, MTX_DEF);
+	cv_init(&request->done_cv, "ATA request done");
+    }
 
     /* in ATA_STALL_QUEUE state we call HW directly */
     if ((ch->state & ATA_STALL_QUEUE) && (request->flags & ATA_R_CONTROL)) {
@@ -74,8 +76,10 @@
 	ch->running = request;
 	if (ch->hw.begin_transaction(request) == ATA_OP_FINISHED) {
 	    ch->running = NULL;
-	    if (!request->callback) 
-		sema_destroy(&request->done);
+	    if (!request->callback) {
+		cv_destroy(&request->done_cv);
+		mtx_destroy(&request->done_mtx);
+	    }
 	    mtx_unlock(&ch->state_mtx);
 	    return;
 	}
@@ -102,16 +106,22 @@
     /* if this is not a callback wait until request is completed */
     if (!request->callback) {
 	ATA_DEBUG_RQ(request, "wait for completition");
-	if (!dumping &&
-	    sema_timedwait(&request->done, request->timeout * hz * 4)) {
-	    device_printf(request->dev,
-			  "WARNING - %s taskqueue timeout "
-			  "- completing request directly\n",
-			  ata_cmd2str(request));
-	    request->flags |= ATA_R_DANGER1;
-	    ata_completed(request, 0);
+	if (!dumping) {
+	    mtx_lock(&request->done_mtx);
+	    if (cv_timedwait(&request->done_cv, &request->done_mtx,
+		request->timeout * hz * 4)) {
+		    mtx_unlock(&request->done_mtx);
+	            device_printf(request->dev,
+			    "WARNING - %s taskqueue timeout "
+			    "- completing request directly\n",
+			    ata_cmd2str(request));
+	    	    request->flags |= ATA_R_DANGER1;
+	    	    ata_completed(request, 0);
+	    }
+	    mtx_unlock(&request->done_mtx);
 	}
-	sema_destroy(&request->done);
+	cv_destroy(&request->done_cv);
+	mtx_destroy(&request->done_mtx);
     }
 }
 
@@ -477,8 +487,11 @@
     /* get results back to the initiator for this request */
     if (request->callback)
 	(request->callback)(request);
-    else
-	sema_post(&request->done);
+    else {
+	mtx_lock(&request->done_mtx);
+	cv_signal(&request->done_cv);
+	mtx_unlock(&request->done_mtx);
+    }
 
     /* only call ata_start if channel is present */
     if (ch)
--- /usr/src/sys/dev/ata/ata-raid.c	Mon Nov  6 12:42:45 2006
+++ ata-raid.c	Sat Dec  2 15:20:17 2006
@@ -37,10 +37,12 @@
 #include <sys/endian.h>
 #include <sys/bio.h>
 #include <sys/bus.h>
+#include <sys/condvar.h>
 #include <sys/conf.h>
 #include <sys/disk.h>
 #include <sys/cons.h>
-#include <sys/sema.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
 #include <sys/taskqueue.h>
 #include <vm/uma.h>
 #include <machine/bus.h>
--- /usr/src/sys/dev/ata/ata-usb.c	Mon Oct  2 03:33:34 2006
+++ ata-usb.c	Sat Dec  2 15:20:54 2006
@@ -35,11 +35,13 @@
 #include <sys/mutex.h>
 #include <sys/ata.h>
 #include <sys/bus.h>
+#include <sys/condvar.h>
 #include <sys/endian.h>
 #include <sys/sysctl.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
 #include <sys/malloc.h>
 #include <sys/module.h>
-#include <sys/sema.h>
 #include <sys/taskqueue.h>
 #include <vm/uma.h>
 #include <machine/resource.h>
--- /usr/src/sys/dev/ata/ata_if.m	Wed Oct  4 07:21:42 2006
+++ ata_if.m	Sat Dec  2 15:21:36 2006
@@ -29,7 +29,9 @@
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/callout.h>
-#include <sys/sema.h>
+#include <sys/condvar.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
 #include <sys/taskqueue.h>
 #include <vm/uma.h>
 #include <machine/bus.h>
--- /usr/src/sys/dev/ata/atapi-cam.c	Mon Nov  6 12:42:45 2006
+++ atapi-cam.c	Sat Dec  2 15:22:00 2006
@@ -32,13 +32,13 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/bus.h>
+#include <sys/condvar.h>
 #include <sys/kernel.h>
 #include <sys/malloc.h>
 #include <sys/ata.h>
 #include <sys/taskqueue.h>
 #include <sys/lock.h>
 #include <sys/mutex.h>
-#include <sys/sema.h>
 #include <vm/uma.h>
 #include <machine/resource.h>
 #include <machine/bus.h>
--- /usr/src/sys/dev/ata/atapi-cd.c	Wed Nov 29 19:21:04 2006
+++ atapi-cd.c	Sat Dec  2 15:22:55 2006
@@ -43,9 +43,11 @@
 #include <sys/dvdio.h>
 #include <sys/disk.h>
 #include <sys/fcntl.h>
+#include <sys/condvar.h>
 #include <sys/conf.h>
 #include <sys/ctype.h>
-#include <sys/sema.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
 #include <sys/taskqueue.h>
 #include <vm/uma.h>
 #include <machine/bus.h>
--- /usr/src/sys/dev/ata/atapi-fd.c	Wed Oct  4 07:21:43 2006
+++ atapi-fd.c	Sat Dec  2 15:23:37 2006
@@ -35,10 +35,12 @@
 #include <sys/malloc.h>
 #include <sys/bio.h>
 #include <sys/bus.h>
+#include <sys/condvar.h>
 #include <sys/conf.h>
 #include <sys/endian.h>
 #include <sys/cdio.h>
-#include <sys/sema.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
 #include <sys/taskqueue.h>
 #include <vm/uma.h>
 #include <machine/bus.h>
--- /usr/src/sys/dev/ata/atapi-tape.c	Wed Oct  4 07:21:43 2006
+++ atapi-tape.c	Sat Dec  2 15:24:13 2006
@@ -37,9 +37,11 @@
 #include <sys/conf.h>
 #include <sys/bio.h>
 #include <sys/bus.h>
+#include <sys/condvar.h>
 #include <sys/mtio.h>
 #include <sys/devicestat.h>
-#include <sys/sema.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
 #include <sys/taskqueue.h>
 #include <vm/uma.h>
 #include <machine/bus.h>
--- /usr/src/sys/dev/ips/ips.c	Sun Oct  8 04:17:47 2006
+++ ips.c	Sun Dec  3 02:16:24 2006
@@ -214,9 +214,6 @@
 void ips_insert_free_cmd(ips_softc_t *sc, ips_command_t *command)
 {
 
-	if (sema_value(&sc->cmd_sema) != 0)
-		panic("ips: command returned non-zero semaphore");
-
 	if (command != sc->staticcmd) {
 		SLIST_INSERT_HEAD(&sc->free_cmd_list, command, next);
 		(sc->used_commands)--;
--- /usr/src/sys/dev/ips/ips.h	Wed Oct  4 07:22:22 2006
+++ ips.h	Sun Dec  3 02:15:10 2006
@@ -37,13 +37,13 @@
 #include <sys/kernel.h>
 #include <sys/module.h>
 #include <sys/bus.h>
+#include <sys/condvar.h>
 #include <sys/conf.h>
 #include <sys/types.h>
 #include <sys/queue.h>
 #include <sys/bio.h>
 #include <sys/malloc.h>
 #include <sys/mutex.h>
-#include <sys/sema.h>
 #include <sys/time.h>
 
 #include <machine/bus.h>
@@ -151,7 +151,8 @@
 	ips_copper_queue_t *	copper_queue;
 	struct mtx		queue_mtx;
 	struct bio_queue_head	queue;
-	struct sema		cmd_sema;
+	struct mtx		cmd_mtx;
+	struct cv		cmd_cv;
 
 }ips_softc_t;
 
--- /usr/src/sys/dev/ips/ips_commands.c	Wed Oct  4 07:22:22 2006
+++ ips_commands.c	Sun Dec  3 02:30:39 2006
@@ -42,7 +42,9 @@
 {
 	bus_dmamap_sync(command->sc->command_dmatag, command->command_dmamap, 
 			BUS_DMASYNC_POSTWRITE);
-	sema_post(&command->sc->cmd_sema);
+	mtx_lock(&command->sc->cmd_mtx);
+	cv_signal(&command->sc->cmd_cv, &command->sc->cmd_mtx);
+	mtx_unlock(&command->sc->cmd_mtx);
 }
 /* Below are a series of functions for sending an IO request
  * to the adapter.  The flow order is: start, send, callback, finish.
@@ -190,10 +192,13 @@
 	bus_dmamap_sync(command->data_dmatag, command->data_dmamap, 
 			BUS_DMASYNC_PREREAD);
 	sc->ips_issue_cmd(command);
-	if (sema_timedwait(&sc->cmd_sema, 30*hz) != 0) {
+	mtx_lock(&sc->cmd_mtx);
+	if (cv_timedwait(&sc->cmd_cv, &sc->cmd_mtx, 30*hz) != 0) {
+		mtx_unlock(&sc->cmd_mtx);
 		ips_set_error(command, ETIMEDOUT);
 		return;
 	}
+	mtx_unlock(&sc->cmd_mtx);
 
 	bus_dmamap_sync(command->data_dmatag, command->data_dmamap, 
 			BUS_DMASYNC_POSTREAD);
@@ -291,10 +296,13 @@
 	bus_dmamap_sync(command->data_dmatag, command->data_dmamap, 
 			BUS_DMASYNC_PREREAD);
 	sc->ips_issue_cmd(command);
-	if (sema_timedwait(&sc->cmd_sema, 10*hz) != 0) {
+	mtx_lock(&sc->cmd_mtx);
+	if (cv_timedwait(&sc->cmd_cv, &sc->cmd_mtx, 10*hz) != 0) {
+		mtx_unlock(&sc->cmd_mtx);
 		ips_set_error(command, ETIMEDOUT);
 		return;
 	}
+	mtx_unlock(&sc->cmd_mtx);
 
 	bus_dmamap_sync(command->data_dmatag, command->data_dmamap, 
 			BUS_DMASYNC_POSTREAD);
@@ -380,8 +388,11 @@
 	bus_dmamap_sync(sc->command_dmatag, command->command_dmamap, 
 			BUS_DMASYNC_PREWRITE);
 	sc->ips_issue_cmd(command);
-	if (COMMAND_ERROR(command) == 0)
-		sema_wait(&sc->cmd_sema);
+	if (COMMAND_ERROR(command) == 0) {
+		mtx_lock(&sc->cmd_mtx);
+		cv_wait(&sc->cmd_cv, &sc->cmd_mtx);
+		mtx_unlock(&sc->cmd_mtx);
+	}
 	ips_insert_free_cmd(sc, command);
 	return 0;
 }
@@ -461,8 +472,11 @@
 	bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
 			BUS_DMASYNC_PREWRITE);
 	sc->ips_issue_cmd(command);
-	if (COMMAND_ERROR(command) == 0)
-		sema_wait(&sc->cmd_sema);
+	if (COMMAND_ERROR(command) == 0) {
+		mtx_lock(&sc->cmd_mtx);
+		cv_wait(&sc->cmd_cv, &sc->cmd_mtx);
+		mtx_unlock(&sc->cmd_mtx);
+	}
 	ips_insert_free_cmd(sc, command);
 	return 0;
 }
@@ -530,10 +544,13 @@
 	bus_dmamap_sync(command->data_dmatag, command->data_dmamap, 
 			BUS_DMASYNC_PREREAD);
 	sc->ips_issue_cmd(command);
-	if (sema_timedwait(&sc->cmd_sema, 30*hz) != 0) {
+	mtx_lock(&sc->cmd_mtx);
+	if (cv_timedwait(&sc->cmd_cv, &sc->cmd_mtx, 30*hz) != 0) {
+		mtx_unlock(&sc->cmd_mtx);
 		ips_set_error(command, ETIMEDOUT);
 		return;
 	}
+	mtx_unlock(&sc->cmd_mtx);
 	bus_dmamap_sync(command->data_dmatag, command->data_dmamap, 
 			BUS_DMASYNC_POSTWRITE);
 }
@@ -614,8 +631,11 @@
 	bus_dmamap_sync(sc->command_dmatag, command->command_dmamap, 
 			BUS_DMASYNC_PREWRITE);
 	sc->ips_issue_cmd(command);
-	if (COMMAND_ERROR(command) == 0)
-		sema_wait(&sc->cmd_sema);
+	if (COMMAND_ERROR(command) == 0) {
+		mtx_lock(&sc->cmd_mtx);
+		cv_wait(&sc->cmd_cv, &sc->cmd_mtx);
+		mtx_unlock(&sc->cmd_mtx);
+	}
 	ips_insert_free_cmd(sc, command);
 	return 0;
 }
@@ -634,8 +654,11 @@
 	bus_dmamap_sync(sc->command_dmatag, command->command_dmamap, 
 			BUS_DMASYNC_PREWRITE);
 	sc->ips_issue_cmd(command);
-	if (COMMAND_ERROR(command) == 0)
-		sema_wait(&sc->cmd_sema);
+	if (COMMAND_ERROR(command) == 0) {
+		mtx_lock(&sc->cmd_mtx);
+		cv_wait(&sc->cmd_cv, &sc->cmd_mtx);
+		mtx_unlock(&sc->cmd_mtx);
+	}
 	ips_insert_free_cmd(sc, command);
 	return 0;
 }
--- /usr/src/sys/dev/ips/ips_pci.c	Wed Oct  4 07:22:22 2006
+++ ips_pci.c	Sun Dec  3 02:40:54 2006
@@ -154,7 +154,8 @@
 	sc->ips_ich.ich_func = ips_intrhook;
 	sc->ips_ich.ich_arg = sc;
 	mtx_init(&sc->queue_mtx, "IPS bioqueue lock", MTX_DEF, 0);
-	sema_init(&sc->cmd_sema, 0, "IPS Command Semaphore");
+	mtx_init(&sc->cmd_mtx, "IPS Command Lock", NULL, MTX_DEF);
+	cv_init(&sc->cmd_cv, "IPS Command Cond");
 	bioq_init(&sc->queue);
 	if (config_intrhook_establish(&sc->ips_ich) != 0) {
 		printf("IPS can't establish configuration hook\n");
@@ -190,7 +191,8 @@
                 bus_release_resource(sc->dev, sc->iotype, sc->rid, sc->iores);
 	sc->configured = 0;
 	mtx_destroy(&sc->queue_mtx);
-	sema_destroy(&sc->cmd_sema);
+	cv_destroy(&sc->cmd_cv);
+	mtx_destroy(&sc->cmd_mtx);
 	return 0;
 }
 
--- /usr/src/sys/kern/vfs_aio.c	Wed Nov 29 19:21:16 2006
+++ vfs_aio.c	Sat Dec  2 14:54:17 2006
@@ -26,6 +26,7 @@
 #include <sys/malloc.h>
 #include <sys/bio.h>
 #include <sys/buf.h>
+#include <sys/condvar.h>
 #include <sys/eventhandler.h>
 #include <sys/sysproto.h>
 #include <sys/filedesc.h>
@@ -43,7 +44,6 @@
 #include <sys/resourcevar.h>
 #include <sys/signalvar.h>
 #include <sys/protosw.h>
-#include <sys/sema.h>
 #include <sys/socket.h>
 #include <sys/socketvar.h>
 #include <sys/syscall.h>
@@ -307,7 +307,8 @@
 #define KAIO_WAKEUP	0x2	/* wakeup process when there is a significant event */
 
 static TAILQ_HEAD(,aiothreadlist) aio_freeproc;		/* (c) Idle daemons */
-static struct sema aio_newproc_sem;
+static struct cv aio_proc_cv;
+static struct mtx aio_proc_mtx;
 static struct mtx aio_job_mtx;
 static struct mtx aio_sock_mtx;
 static TAILQ_HEAD(,aiocblist) aio_jobs;			/* (c) Async job list */
@@ -425,7 +426,8 @@
 	kqueue_add_filteropts(EVFILT_AIO, &aio_filtops);
 	kqueue_add_filteropts(EVFILT_LIO, &lio_filtops);
 	TAILQ_INIT(&aio_freeproc);
-	sema_init(&aio_newproc_sem, 0, "aio_new_proc");
+	mtx_init(&aio_proc_mtx, "aio_new_proc lock", NULL, MTX_DEF);
+	cv_init(&aio_proc_cv, "aio_new_proc");
 	mtx_init(&aio_job_mtx, "aio_job", NULL, MTX_DEF);
 	mtx_init(&aio_sock_mtx, "aio_sock", NULL, MTX_DEF);
 	TAILQ_INIT(&aio_jobs);
@@ -487,7 +489,8 @@
 	EVENTHANDLER_DEREGISTER(process_exec, exec_tag);
 	mtx_destroy(&aio_job_mtx);
 	mtx_destroy(&aio_sock_mtx);
-	sema_destroy(&aio_newproc_sem);
+	cv_destroy(&aio_proc_cv);
+	mtx_destroy(&aio_proc_mtx);
 	p31b_setcfg(CTL_P1003_1B_AIO_LISTIO_MAX, -1);
 	p31b_setcfg(CTL_P1003_1B_AIO_MAX, -1);
 	p31b_setcfg(CTL_P1003_1B_AIO_PRIO_DELTA_MAX, -1);
@@ -984,7 +987,9 @@
 	 * Wakeup parent process.  (Parent sleeps to keep from blasting away
 	 * and creating too many daemons.)
 	 */
-	sema_post(&aio_newproc_sem);
+	mtx_lock(&aio_proc_mtx);
+	cv_wait(&aio_proc_cv, &aio_proc_mtx);
+	mtx_unlock(&aio_proc_mtx);
 
 	mtx_lock(&aio_job_mtx);
 	for (;;) {
@@ -1147,7 +1152,9 @@
 		/*
 		 * Wait until daemon is started.
 		 */
-		sema_wait(&aio_newproc_sem);
+		mtx_lock(&aio_proc_mtx);
+		cv_wait(&aio_proc_cv, &aio_proc_mtx);
+		mtx_unlock(&aio_proc_mtx);
 		mtx_lock(&aio_job_mtx);
 		num_aio_procs++;
 		if (start != NULL)
