Date: Wed, 21 Jun 2006 08:29:36 GMT From: Scott Long <scottl@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 99735 for review Message-ID: <200606210829.k5L8Ta0G039548@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606210829.k5L8Ta0G039548>