PERFORCE change 116676 for review

Scott Long scottl at FreeBSD.org
Tue Mar 27 17:12:29 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=116676

Change 116676 by scottl at scottl-x64 on 2007/03/27 17:11:47

	Lock the scsi_ch driver, remove spl markers.

Affected files ...

.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_ch.c#8 edit

Differences ...

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

@@ -173,8 +173,6 @@
 	int		sc_settledelay;	/* delay for settle */
 };
 
-#define CHUNIT(x)       (minor((x)))
-
 static	d_open_t	chopen;
 static	d_close_t	chclose;
 static	d_ioctl_t	chioctl;
@@ -213,7 +211,7 @@
 
 static struct cdevsw ch_cdevsw = {
 	.d_version =	D_VERSION,
-	.d_flags =	D_NEEDGIANT,
+	.d_flags =	0,
 	.d_open =	chopen,
 	.d_close =	chclose,
 	.d_ioctl =	chioctl,
@@ -407,23 +405,24 @@
 	int error;
 
 	periph = (struct cam_periph *)dev->si_drv1;
-	if (periph == NULL)
-		return(ENXIO);
+	if (cam_periph_acquire(periph) != CAM_REQ_CMP)
+		return (ENXIO);
 
 	softc = (struct ch_softc *)periph->softc;
 
+	cam_periph_lock(periph);
+	
 	if (softc->flags & CH_FLAG_INVALID) {
+		cam_periph_unlock(periph);
+		cam_periph_release(periph);
 		return(ENXIO);
 	}
 
-	if ((softc->flags & CH_FLAG_OPEN) == 0) {
-		if (cam_periph_acquire(periph) != CAM_REQ_CMP)
-			return(ENXIO);
+	if ((softc->flags & CH_FLAG_OPEN) == 0)
 		softc->flags |= CH_FLAG_OPEN;
-	}
+	else
+		cam_periph_release(periph);
 
-	cam_periph_lock(periph);
-	
 	/*
 	 * Load information about this changer device into the softc.
 	 */
@@ -468,24 +467,20 @@
 chstart(struct cam_periph *periph, union ccb *start_ccb)
 {
 	struct ch_softc *softc;
-	int s;
 
 	softc = (struct ch_softc *)periph->softc;
 
 	switch (softc->state) {
 	case CH_STATE_NORMAL:
 	{
-		s = splbio();
 		if (periph->immediate_priority <= periph->pinfo.priority){
 			start_ccb->ccb_h.ccb_state = CH_CCB_WAITING;
 
 			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
-			splx(s);
+		}
 		break;
 	}
 	case CH_STATE_PROBE:
@@ -745,8 +740,10 @@
 	{
 		int new_picker = *(int *)addr;
 
-		if (new_picker > (softc->sc_counts[CHET_MT] - 1))
-			return (EINVAL);
+		if (new_picker > (softc->sc_counts[CHET_MT] - 1)) {
+			error = EINVAL;
+			break;
+		}
 		softc->sc_picker = softc->sc_firsts[CHET_MT] + new_picker;
 		break;
 	}


More information about the p4-projects mailing list