From owner-p4-projects@FreeBSD.ORG Wed Jun 21 08:29:38 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 1DEAD16A47B; Wed, 21 Jun 2006 08:29:38 +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 ECB4E16A474 for ; Wed, 21 Jun 2006 08:29:37 +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 7893E43D49 for ; Wed, 21 Jun 2006 08:29:37 +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 k5L8TbDK039551 for ; Wed, 21 Jun 2006 08:29:37 GMT (envelope-from scottl@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k5L8Ta0G039548 for perforce@freebsd.org; Wed, 21 Jun 2006 08:29:36 GMT (envelope-from scottl@freebsd.org) Date: Wed, 21 Jun 2006 08:29:36 GMT Message-Id: <200606210829.k5L8Ta0G039548@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 99735 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, 21 Jun 2006 08:29:38 -0000 http://perforce.freebsd.org/chv.cgi?CH=99735 Change 99735 by scottl@scottl-wv1u on 2006/06/21 08:29:14 CAM_PERIPH_LOCK/CAM_PERIPH_UNLOCK are used to take the SIM lock in the periph. Also fix a mistake with the order of locking in the close routines. Affected files ... .. //depot/projects/scottl-camlock/src/sys/cam/cam_periph.h#8 edit .. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_da.c#12 edit .. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_pass.c#10 edit .. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_ses.c#8 edit Differences ... ==== //depot/projects/scottl-camlock/src/sys/cam/cam_periph.h#8 (text+ko) ==== @@ -126,6 +126,9 @@ #define CAM_PERIPH_MAXMAPS 2 +#define CAM_PERIPH_LOCK(periph) mtx_lock((periph)->sim->mtx) +#define CAM_PERIPH_UNLOCK(periph) mtx_unlock((periph)->sim->mtx) + struct cam_periph_map_info { int num_bufs_used; struct buf *bp[CAM_PERIPH_MAXMAPS]; ==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_da.c#12 (text+ko) ==== @@ -540,7 +540,7 @@ return (error); /* error code from tsleep */ if (cam_periph_acquire(periph) != CAM_REQ_CMP) { - mtx_unlock(periph->sim->mtx); + CAM_PERIPH_UNLOCK(periph); return(ENXIO); } @@ -658,8 +658,8 @@ } softc->flags &= ~DA_FLAG_OPEN; + cam_periph_release(periph); cam_periph_unlock(periph); - cam_periph_release(periph); return (0); } @@ -682,7 +682,7 @@ } softc = (struct da_softc *)periph->softc; - mtx_lock(periph->sim->mtx); + CAM_PERIPH_LOCK(periph); #if 0 /* @@ -703,7 +703,7 @@ */ if ((softc->flags & DA_FLAG_PACK_INVALID)) { splx(s); - mtx_unlock(periph->sim->mtx); + CAM_PERIPH_UNLOCK(periph); biofinish(bp, NULL, ENXIO); return; } @@ -719,7 +719,7 @@ * Schedule ourselves for performing the work. */ xpt_schedule(periph, /* XXX priority */1); - mtx_unlock(periph->sim->mtx); + CAM_PERIPH_UNLOCK(periph); return; } ==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_pass.c#10 (text+ko) ==== @@ -409,8 +409,8 @@ softc = (struct pass_softc *)periph->softc; softc->flags &= ~PASS_FLAG_OPEN; + cam_periph_release(periph); cam_periph_unlock(periph); - cam_periph_release(periph); return (0); } @@ -464,8 +464,8 @@ if (periph == NULL) return(ENXIO); + CAM_PERIPH_LOCK(periph); softc = (struct pass_softc *)periph->softc; - mtx_lock(periph->sim->mtx); error = 0; @@ -532,7 +532,7 @@ break; } - mtx_unlock(periph->sim->mtx); + CAM_PERIPH_UNLOCK(periph); return(error); } ==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_ses.c#8 (text+ko) ==== @@ -483,8 +483,8 @@ softc = (struct ses_softc *)periph->softc; softc->ses_flags &= ~SES_FLAG_OPEN; + cam_periph_release(periph); cam_periph_unlock(periph); - cam_periph_release(periph); return (0); } @@ -542,17 +542,17 @@ CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("entering sesioctl\n")); - mtx_lock(periph->sim->mtx); + CAM_PERIPH_LOCK(periph); ssc = (struct ses_softc *)periph->softc; /* * Now check to see whether we're initialized or not. */ if ((ssc->ses_flags & SES_FLAG_INITIALIZED) == 0) { - mtx_unlock(periph->sim->mtx); + CAM_PERIPH_UNLOCK(periph); return (ENXIO); } - mtx_unlock(periph->sim->mtx); + CAM_PERIPH_UNLOCK(periph); error = 0; @@ -586,30 +586,30 @@ * XXX Dropping the lock while copying multiple segments is * bogus. */ - mtx_lock(periph->sim->mtx); + CAM_PERIPH_LOCK(periph); for (uobj = addr, i = 0; i != ssc->ses_nobjects; i++, uobj++) { obj.obj_id = i; obj.subencid = ssc->ses_objmap[i].subenclosure; obj.object_type = ssc->ses_objmap[i].enctype; - mtx_unlock(periph->sim->mtx); + CAM_PERIPH_UNLOCK(periph); error = copyout(&obj, uobj, sizeof (ses_object)); - mtx_lock(periph->sim->mtx); + CAM_PERIPH_LOCK(periph); if (error) { break; } } - mtx_unlock(periph->sim->mtx); + CAM_PERIPH_UNLOCK(periph); break; case SESIOC_GETENCSTAT: - mtx_lock(periph->sim->mtx); + CAM_PERIPH_LOCK(periph); error = (*ssc->ses_vec.get_encstat)(ssc, 1); if (error) { - mtx_unlock(periph->sim->mtx); + CAM_PERIPH_UNLOCK(periph); break; } tmp = ssc->ses_encstat & ~ENCI_SVALID; - mtx_unlock(periph->sim->mtx); + CAM_PERIPH_UNLOCK(periph); error = copyout(&tmp, addr, sizeof (ses_encstat)); ssc->ses_encstat = tmp; break; @@ -618,9 +618,9 @@ error = copyin(addr, &tmp, sizeof (ses_encstat)); if (error) break; - mtx_lock(periph->sim->mtx); + CAM_PERIPH_LOCK(periph); error = (*ssc->ses_vec.set_encstat)(ssc, tmp, 1); - mtx_unlock(periph->sim->mtx); + CAM_PERIPH_UNLOCK(periph); break; case SESIOC_GETOBJSTAT: @@ -631,9 +631,9 @@ error = EINVAL; break; } - mtx_lock(periph->sim->mtx); + CAM_PERIPH_LOCK(periph); error = (*ssc->ses_vec.get_objstat)(ssc, &objs, 1); - mtx_unlock(periph->sim->mtx); + CAM_PERIPH_UNLOCK(periph); if (error) break; error = copyout(&objs, addr, sizeof (ses_objstat)); @@ -652,9 +652,9 @@ error = EINVAL; break; } - mtx_lock(periph->sim->mtx); + CAM_PERIPH_LOCK(periph); error = (*ssc->ses_vec.set_objstat)(ssc, &objs, 1); - mtx_unlock(periph->sim->mtx); + CAM_PERIPH_UNLOCK(periph); /* * Always (for now) invalidate entry. @@ -664,15 +664,15 @@ case SESIOC_INIT: - mtx_lock(periph->sim->mtx); + CAM_PERIPH_LOCK(periph); error = (*ssc->ses_vec.init_enc)(ssc); - mtx_unlock(periph->sim->mtx); + CAM_PERIPH_UNLOCK(periph); break; default: - mtx_lock(periph->sim->mtx); + CAM_PERIPH_LOCK(periph); error = cam_periph_ioctl(periph, cmd, arg_addr, seserror); - mtx_unlock(periph->sim->mtx); + CAM_PERIPH_UNLOCK(periph); break; } return (error);