Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Mar 2007 16:53:03 GMT
From:      Scott Long <scottl@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 116673 for review
Message-ID:  <200703271653.l2RGr3Nw015403@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=116673

Change 116673 by scottl@scottl-x64 on 2007/03/27 16:52:06

	Lock the scsi_pt driver and remove spl markers.

Affected files ...

.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_pt.c#7 edit

Differences ...

==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_pt.c#7 (text+ko) ====

@@ -119,7 +119,7 @@
 
 static struct cdevsw pt_cdevsw = {
 	.d_version =	D_VERSION,
-	.d_flags =	D_NEEDGIANT,
+	.d_flags =	0,
 	.d_open =	ptopen,
 	.d_close =	ptclose,
 	.d_read =	physread,
@@ -138,38 +138,31 @@
 {
 	struct cam_periph *periph;
 	struct pt_softc *softc;
-	int unit;
 	int error = 0;
-	int s;
 
-	unit = minor(dev);
 	periph = (struct cam_periph *)dev->si_drv1;
-	if (periph == NULL)
+	if (cam_periph_acquire(periph) != CAM_REQ_CMP)
 		return (ENXIO);	
 
 	softc = (struct pt_softc *)periph->softc;
 
-	s = splsoftcam();
+	cam_periph_lock(periph);
 	if (softc->flags & PT_FLAG_DEVICE_INVALID) {
-		splx(s);
+		cam_periph_unlock(periph);
+		cam_periph_release(periph);
 		return(ENXIO);
 	}
 
-	if ((softc->flags & PT_FLAG_OPEN) == 0) {
-		if (cam_periph_acquire(periph) != CAM_REQ_CMP)
-			error = ENXIO;
-		else
-			softc->flags |= PT_FLAG_OPEN;
-	} else
+	if ((softc->flags & PT_FLAG_OPEN) == 0)
+		softc->flags |= PT_FLAG_OPEN;
+	else {
 		error = EBUSY;
-
-	cam_periph_lock(periph);
+		cam_periph_release(periph);
+	}
 
 	CAM_DEBUG(periph->path, CAM_DEBUG_TRACE,
-	    ("ptopen: dev=%s (unit %d)\n", devtoname(dev), unit));
+	    ("ptopen: dev=%s\n", devtoname(dev)));
 
-	splx(s);
-
 	cam_periph_unlock(periph);
 	return (error);
 }
@@ -204,7 +197,6 @@
 {
 	struct cam_periph *periph;
 	struct pt_softc *softc;
-	int    s;
 	
 	periph = (struct cam_periph *)bp->bio_dev->si_drv1;
 	bp->bio_resid = bp->bio_bcount;
@@ -212,20 +204,14 @@
 		biofinish(bp, NULL, ENXIO);
 		return;
 	}
+	cam_periph_lock(periph);
 	softc = (struct pt_softc *)periph->softc;
 
 	/*
-	 * Mask interrupts so that the pack cannot be invalidated until
-	 * after we are in the queue.  Otherwise, we might not properly
-	 * clean up one of the buffers.
-	 */
-	s = splbio();
-	
-	/*
 	 * If the device has been made invalid, error out
 	 */
 	if ((softc->flags & PT_FLAG_DEVICE_INVALID)) {
-		splx(s);
+		cam_periph_unlock(periph);
 		biofinish(bp, NULL, ENXIO);
 		return;
 	}
@@ -235,12 +221,11 @@
 	 */
 	bioq_insert_tail(&softc->bio_queue, bp);
 
-	splx(s);
-	
 	/*
 	 * Schedule ourselves for performing the work.
 	 */
 	xpt_schedule(periph, /* XXX priority */1);
+	cam_periph_unlock(periph);
 
 	return;
 }
@@ -347,7 +332,6 @@
 static void
 ptoninvalidate(struct cam_periph *periph)
 {
-	int s;
 	struct pt_softc *softc;
 	struct ccb_setasync csa;
 
@@ -367,21 +351,12 @@
 	softc->flags |= PT_FLAG_DEVICE_INVALID;
 
 	/*
-	 * Although the oninvalidate() routines are always called at
-	 * splsoftcam, we need to be at splbio() here to keep the buffer
-	 * queue from being modified while we traverse it.
-	 */
-	s = splbio();
-
-	/*
 	 * Return all queued I/O with ENXIO.
 	 * XXX Handle any transactions queued to the card
 	 *     with XPT_ABORT_CCB.
 	 */
 	bioq_flush(&softc->bio_queue, NULL, ENXIO);
 
-	splx(s);
-
 	xpt_print(periph->path, "lost device\n");
 }
 
@@ -440,10 +415,8 @@
 	{
 		struct pt_softc *softc;
 		struct ccb_hdr *ccbh;
-		int s;
 
 		softc = (struct pt_softc *)periph->softc;
-		s = splsoftcam();
 		/*
 		 * Don't fail on the expected unit attention
 		 * that will occur.
@@ -451,7 +424,6 @@
 		softc->flags |= PT_FLAG_RETRY_UA;
 		LIST_FOREACH(ccbh, &softc->pending_ccbs, periph_links.le)
 			ccbh->ccb_state |= PT_CCB_RETRY_UA;
-		splx(s);
 	}
 	/* FALLTHROUGH */
 	default:
@@ -465,14 +437,12 @@
 {
 	struct pt_softc *softc;
 	struct bio *bp;
-	int s;
 
 	softc = (struct pt_softc *)periph->softc;
 
 	/*
 	 * See if there is a buf with work for us to do..
 	 */
-	s = splbio();
 	bp = bioq_first(&softc->bio_queue);
 	if (periph->immediate_priority <= periph->pinfo.priority) {
 		CAM_DEBUG_PRINT(CAM_DEBUG_SUBTRACE,
@@ -481,14 +451,10 @@
 		SLIST_INSERT_HEAD(&periph->ccb_list, &start_ccb->ccb_h,
 				  periph_links.sle);
 		periph->immediate_priority = CAM_PRIORITY_NONE;
-		splx(s);
 		wakeup(&periph->ccb_list);
 	} else if (bp == NULL) {
-		splx(s);
 		xpt_release_ccb(start_ccb);
 	} else {
-		int oldspl;
-
 		bioq_remove(&softc->bio_queue, bp);
 
 		devstat_start_transaction_bio(softc->device_stats, bp);
@@ -510,14 +476,11 @@
 		 * Block out any asyncronous callbacks
 		 * while we touch the pending ccb list.
 		 */
-		oldspl = splcam();
 		LIST_INSERT_HEAD(&softc->pending_ccbs, &start_ccb->ccb_h,
 				 periph_links.le);
-		splx(oldspl);
 
 		start_ccb->ccb_h.ccb_bp = bp;
 		bp = bioq_first(&softc->bio_queue);
-		splx(s);
 
 		xpt_action(start_ccb);
 		
@@ -541,12 +504,10 @@
 	case PT_CCB_BUFFER_IO_UA:
 	{
 		struct bio *bp;
-		int    oldspl;
 
 		bp = (struct bio *)done_ccb->ccb_h.ccb_bp;
 		if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
 			int error;
-			int s;
 			int sf;
 			
 			if ((csio->ccb_h.ccb_state & PT_CCB_RETRY_UA) != 0)
@@ -563,8 +524,6 @@
 				return;
 			}
 			if (error != 0) {
-				s = splbio();
-
 				if (error == ENXIO) {
 					/*
 					 * Catastrophic error.  Mark our device
@@ -581,7 +540,6 @@
 				 * proper order should it attempt to recover.
 				 */
 				bioq_flush(&softc->bio_queue, NULL, EIO);
-				splx(s);
 				bp->bio_error = error;
 				bp->bio_resid = bp->bio_bcount;
 				bp->bio_flags |= BIO_ERROR;
@@ -609,9 +567,7 @@
 		 * Block out any asyncronous callbacks
 		 * while we touch the pending ccb list.
 		 */
-		oldspl = splcam();
 		LIST_REMOVE(&done_ccb->ccb_h, periph_links.le);
-		splx(oldspl);
 
 		biofinish(bp, softc->device_stats, 0);
 		break;
@@ -660,20 +616,14 @@
 			*(int *)addr = 0;
 		break;
 	case PTIOCSETTIMEOUT:
-	{
-		int s;
-
 		if (*(int *)addr < 1) {
 			error = EINVAL;
 			break;
 		}
 
-		s = splsoftcam();
 		softc->io_timeout = *(int *)addr * 1000;
-		splx(s);
 
 		break;
-	}
 	default:
 		error = cam_periph_ioctl(periph, cmd, addr, pterror);
 		break;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200703271653.l2RGr3Nw015403>