From owner-p4-projects@FreeBSD.ORG Thu Feb 23 17:24:51 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D24E216A423; Thu, 23 Feb 2006 17:24:50 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 965C416A420 for ; Thu, 23 Feb 2006 17:24:50 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 60E2543D48 for ; Thu, 23 Feb 2006 17:24:50 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k1NHOoFn010272 for ; Thu, 23 Feb 2006 17:24:50 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k1NHOo0p010269 for perforce@freebsd.org; Thu, 23 Feb 2006 17:24:50 GMT (envelope-from jhb@freebsd.org) Date: Thu, 23 Feb 2006 17:24:50 GMT Message-Id: <200602231724.k1NHOo0p010269@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 92273 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Feb 2006 17:24:51 -0000 http://perforce.freebsd.org/chv.cgi?CH=92273 Change 92273 by jhb@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]);