PERFORCE change 92273 for review

John Baldwin jhb at FreeBSD.org
Thu Feb 23 09:24:51 PST 2006


http://perforce.freebsd.org/chv.cgi?CH=92273

Change 92273 by jhb at jhb_slimer on 2006/02/23 17:24:25

	Use callout_init_mtx().  Now callout_stop() while holding the mutex
	will definitely stop the callout, so the callout_drain() isn't even
	needed anymore.

Affected files ...

.. //depot/projects/smpng/sys/dev/fdc/fdc.c#21 edit

Differences ...

==== //depot/projects/smpng/sys/dev/fdc/fdc.c#21 (text+ko) ====

@@ -616,7 +616,7 @@
 	int once;
 
 	fd = arg;
-	mtx_lock(&fd->fdc->fdc_mtx);
+	mtx_assert(&fd->fdc->fdc_mtx, MA_OWNED);
 	fd->flags &= ~FD_MOTORWAIT;
 	fd->flags |= FD_MOTOR;
 	once = 0;
@@ -627,7 +627,6 @@
 		bioq_disksort(&fd->fdc->head, bp);
 		once = 1;
 	}
-	mtx_unlock(&fd->fdc->fdc_mtx);
 	if (once)
 		wakeup(&fd->fdc->head);
 }
@@ -646,11 +645,6 @@
 		fdc->fdout |= (FDO_MOEN0 << fd->fdsu);
 		callout_reset(&fd->toffhandle, hz, fd_turnon, fd);
 	} else {
-		/*
-		 * We can't call drain from a callout and we can't call it
-		 * while holding a lock needed by the callout being drained,
-		 * so use stop for now.
-		 */
 		callout_stop(&fd->toffhandle);
 		fd->flags &= ~(FD_MOTOR|FD_MOTORWAIT);
 		fdc->fdout &= ~(FDO_MOEN0 << fd->fdsu);
@@ -663,9 +657,8 @@
 {
 	struct fd_data *fd = xfd;
 
-	mtx_lock(&fd->fdc->fdc_mtx);
+	mtx_assert(&fd->fdc->fdc_mtx, MA_OWNED);
 	fd_motor(fd, 0);
-	mtx_unlock(&fd->fdc->fdc_mtx);
 }
 
 /*
@@ -1203,7 +1196,6 @@
 	mtx_lock(&fdc->fdc_mtx);
 	/* If we go from idle, cancel motor turnoff */
 	if (fd->fd_iocount++ == 0)
-		/* XXX: Can't drain while holding mutex. */
 		callout_stop(&fd->toffhandle);
 	if (fd->flags & FD_MOTOR) {
 		/* The motor is on, send it directly to the controller */
@@ -1944,7 +1936,7 @@
 	fd->fdc = fdc;
 	fd->fdsu = fdsu;
 	fd->options = 0;
-	callout_init(&fd->toffhandle, 1);
+	callout_init_mtx(&fd->toffhandle, &fd->fdc->fdc_mtx, 0);
 
 	/* initialize densities for subdevices */
 	fdsettype(fd, fd_native_types[fd->type]);


More information about the p4-projects mailing list