From owner-p4-projects@FreeBSD.ORG Wed Nov 1 01:12:02 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 4F89216A417; Wed, 1 Nov 2006 01:12:02 +0000 (UTC) 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 12DBA16A403 for ; Wed, 1 Nov 2006 01:12:02 +0000 (UTC) (envelope-from scottl@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 86F9843D5A for ; Wed, 1 Nov 2006 01:12:01 +0000 (GMT) (envelope-from scottl@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id kA11C1s1066214 for ; Wed, 1 Nov 2006 01:12:01 GMT (envelope-from scottl@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id kA11C1Jt066210 for perforce@freebsd.org; Wed, 1 Nov 2006 01:12:01 GMT (envelope-from scottl@freebsd.org) Date: Wed, 1 Nov 2006 01:12:01 GMT Message-Id: <200611010112.kA11C1Jt066210@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to scottl@freebsd.org using -f From: Scott Long To: Perforce Change Reviews Cc: Subject: PERFORCE change 108878 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: Wed, 01 Nov 2006 01:12:02 -0000 http://perforce.freebsd.org/chv.cgi?CH=108878 Change 108878 by scottl@scottl-x64 on 2006/11/01 01:11:30 For some wonderful reason, you cannot pass &Giant to msleep. Work around that in a crude fashion. Also add some more assertions. Affected files ... .. //depot/projects/scottl-camlock/src/sys/cam/cam_periph.c#14 edit Differences ... ==== //depot/projects/scottl-camlock/src/sys/cam/cam_periph.c#14 (text+ko) ==== @@ -515,14 +515,16 @@ /* * Interlock the SIM lock with the XPT lock to protect against the * SIM going away unexpectedly while we are trying reference it. + xpt_lock_buses(); */ - xpt_lock_buses(); /* * Now it's safe to take the SIM lock. */ mtx_lock(periph->sim->mtx); + /* xpt_unlock_buses(); + */ /* * Increment the reference count on the peripheral. @@ -757,9 +759,11 @@ cam_periph_getccb(struct cam_periph *periph, u_int32_t priority) { struct ccb_hdr *ccb_h; + struct mtx *mtx; int s; CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("entering cdgetccb\n")); + mtx_assert(periph->sim->mtx, MA_OWNED); s = splsoftcam(); @@ -770,7 +774,12 @@ if ((SLIST_FIRST(&periph->ccb_list) != NULL) && (SLIST_FIRST(&periph->ccb_list)->pinfo.priority == priority)) break; - msleep(&periph->ccb_list, periph->sim->mtx, PRIBIO, "cgticb", 0); + mtx_assert(periph->sim->mtx, MA_OWNED); + if (periph->sim->mtx == &Giant) + mtx = NULL; + else + mtx = periph->sim->mtx; + msleep(&periph->ccb_list, mtx, PRIBIO, "cgticb", 0); } ccb_h = SLIST_FIRST(&periph->ccb_list); @@ -782,14 +791,19 @@ void cam_periph_ccbwait(union ccb *ccb) { + struct mtx *mtx; struct cam_sim *sim; int s; s = splsoftcam(); sim = xpt_path_sim(ccb->ccb_h.path); + if (sim->mtx == &Giant) + mtx = NULL; + else + mtx = sim->mtx; if ((ccb->ccb_h.pinfo.index != CAM_UNQUEUED_INDEX) || ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_INPROG)) - msleep(&ccb->ccb_h.cbfcnp, sim->mtx, PRIBIO, "cbwait", 0); + msleep(&ccb->ccb_h.cbfcnp, mtx, PRIBIO, "cbwait", 0); splx(s); } @@ -864,10 +878,13 @@ cam_flags camflags, u_int32_t sense_flags, struct devstat *ds) { + struct cam_sim *sim; int error; error = 0; - + sim = xpt_path_sim(ccb->ccb_h.path); + + mtx_assert(sim->mtx, MA_OWNED); /* * If the user has supplied a stats structure, and if we understand * this particular type of ccb, record the transaction start.