PERFORCE change 118565 for review

Matt Jacob mjacob at FreeBSD.org
Sun Apr 22 06:59:24 UTC 2007


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

Change 118565 by mjacob at mjexp on 2007/04/22 06:58:34

	Strip all previous locking out/down to the bare bones in preparation
	for rethinking based upon the new CAM locking model.

Affected files ...

.. //depot/projects/mjexp/sys/dev/isp/isp_freebsd.c#18 edit
.. //depot/projects/mjexp/sys/dev/isp/isp_freebsd.h#12 edit
.. //depot/projects/mjexp/sys/dev/isp/isp_pci.c#22 edit
.. //depot/projects/mjexp/sys/dev/isp/isp_sbus.c#11 edit

Differences ...

==== //depot/projects/mjexp/sys/dev/isp/isp_freebsd.c#18 (text+ko) ====

@@ -135,22 +135,17 @@
 	/*
 	 * Construct our SIM entry.
 	 */
-	ISPLOCK_2_CAMLOCK(isp);
-	sim = cam_sim_alloc(isp_action, isp_poll, "isp", isp,
-	    device_get_unit(isp->isp_dev), &Giant, 1, isp->isp_maxcmds, devq);
+	sim = isp_sim_alloc(isp_action, isp_poll, "isp", isp,
+	    device_get_unit(isp->isp_dev), 1, isp->isp_maxcmds, devq);
 	if (sim == NULL) {
 		cam_simq_free(devq);
-		CAMLOCK_2_ISPLOCK(isp);
 		return;
 	}
-	CAMLOCK_2_ISPLOCK(isp);
 
 	isp->isp_osinfo.ehook.ich_func = isp_intr_enable;
 	isp->isp_osinfo.ehook.ich_arg = isp;
-	ISPLOCK_2_CAMLOCK(isp);
 	if (config_intrhook_establish(&isp->isp_osinfo.ehook) != 0) {
 		cam_sim_free(sim, TRUE);
-		CAMLOCK_2_ISPLOCK(isp);
 		isp_prt(isp, ISP_LOGERR,
 		    "could not establish interrupt enable hook");
 		return;
@@ -158,7 +153,6 @@
 
 	if (xpt_bus_register(sim, primary) != CAM_SUCCESS) {
 		cam_sim_free(sim, TRUE);
-		CAMLOCK_2_ISPLOCK(isp);
 		return;
 	}
 
@@ -167,7 +161,6 @@
 		xpt_bus_deregister(cam_sim_path(sim));
 		cam_sim_free(sim, TRUE);
 		config_intrhook_disestablish(&isp->isp_osinfo.ehook);
-		CAMLOCK_2_ISPLOCK(isp);
 		return;
 	}
 
@@ -177,7 +170,6 @@
 	csa.callback = isp_cam_async;
 	csa.callback_arg = sim;
 	xpt_action((union ccb *)&csa);
-	CAMLOCK_2_ISPLOCK(isp);
 	isp->isp_sim = sim;
 	isp->isp_path = path;
 	/*
@@ -185,9 +177,7 @@
 	 * don't have dual channel FC cards.
 	 */
 	if (IS_FC(isp)) {
-		ISPLOCK_2_CAMLOCK(isp);
 #if __FreeBSD_version >= 500000  
-		cv_init(&isp->isp_osinfo.kthread_cv, "isp_kthread_cv");
 		if (kthread_create(isp_kthread, isp, &isp->isp_osinfo.kproc,
 		    RFHIGHPID, 0, "%s: fc_thrd",
 		    device_get_nameunit(isp->isp_dev)))
@@ -199,11 +189,9 @@
 			xpt_bus_deregister(cam_sim_path(sim));
 			cam_sim_free(sim, TRUE);
 			config_intrhook_disestablish(&isp->isp_osinfo.ehook);
-			CAMLOCK_2_ISPLOCK(isp);
 			isp_prt(isp, ISP_LOGERR, "could not create kthread");
 			return;
 		}
-		CAMLOCK_2_ISPLOCK(isp);
 		/*
 		 * We start by being "loop down" if we have an initiator role
 		 */
@@ -222,10 +210,8 @@
 	 * If we have a second channel, construct SIM entry for that.
 	 */
 	if (IS_DUALBUS(isp)) {
-		ISPLOCK_2_CAMLOCK(isp);
-		sim = cam_sim_alloc(isp_action, isp_poll, "isp", isp,
-		    device_get_unit(isp->isp_dev), &Giant, 1,
-		    isp->isp_maxcmds, devq);
+		sim = isp_sim_alloc(isp_action, isp_poll, "isp", isp,
+		    device_get_unit(isp->isp_dev), 1, isp->isp_maxcmds, devq);
 		if (sim == NULL) {
 			xpt_bus_deregister(cam_sim_path(isp->isp_sim));
 			xpt_free_path(isp->isp_path);
@@ -238,7 +224,6 @@
 			xpt_free_path(isp->isp_path);
 			cam_sim_free(sim, TRUE);
 			config_intrhook_disestablish(&isp->isp_osinfo.ehook);
-			CAMLOCK_2_ISPLOCK(isp);
 			return;
 		}
 
@@ -249,7 +234,6 @@
 			xpt_bus_deregister(cam_sim_path(sim));
 			cam_sim_free(sim, TRUE);
 			config_intrhook_disestablish(&isp->isp_osinfo.ehook);
-			CAMLOCK_2_ISPLOCK(isp);
 			return;
 		}
 
@@ -259,7 +243,6 @@
 		csa.callback = isp_cam_async;
 		csa.callback_arg = sim;
 		xpt_action((union ccb *)&csa);
-		CAMLOCK_2_ISPLOCK(isp);
 		isp->isp_sim2 = sim;
 		isp->isp_path2 = path;
 	}
@@ -292,9 +275,7 @@
 	if (isp->isp_osinfo.simqfrozen == 0) {
 		isp_prt(isp, ISP_LOGDEBUG0, "%s: freeze simq (loopdown)", msg);
 		isp->isp_osinfo.simqfrozen |= SIMQFRZ_LOOPDOWN;
-		ISPLOCK_2_CAMLOCK(isp);
 		xpt_freeze_simq(isp->isp_sim, 1);
-		CAMLOCK_2_ISPLOCK(isp);
 	} else {
 		isp_prt(isp, ISP_LOGDEBUG0, "%s: mark frozen (loopdown)", msg);
 		isp->isp_osinfo.simqfrozen |= SIMQFRZ_LOOPDOWN;
@@ -315,6 +296,11 @@
 {
 	ispsoftc_t *isp;
 	int nr, retval = ENOTTY;
+#if __FreeBSD_version < 500000  
+	int s = splcam();
+#else
+	GIANT_REQUIRED;
+#endif
 
 	isp = isplist;
 	while (isp) {
@@ -323,8 +309,12 @@
 		}
 		isp = isp->isp_osinfo.next;
 	}
-	if (isp == NULL)
+	if (isp == NULL) {
+#if __FreeBSD_version < 500000  
+		splx(s);
+#endif
 		return (ENXIO);
+	}
 	
 	switch (c) {
 #ifdef	ISP_FW_CRASH_DUMP
@@ -339,7 +329,6 @@
 			} else {
 				sz = QLA2300_RISC_IMAGE_DUMP_SIZE;
 			}
-			ISP_LOCK(isp);
 			if (ptr && *ptr) {
 				void *uaddr = *((void **) addr);
 				if (copyout(ptr, uaddr, sz)) {
@@ -350,17 +339,14 @@
 			} else {
 				retval = ENXIO;
 			}
-			ISP_UNLOCK(isp);
 		}
 		break;
 	case ISP_FORCE_CRASH_DUMP:
 		if (IS_FC(isp)) {
-			ISP_LOCK(isp);
 			isp_freeze_loopdown(isp,
 			    "ispioctl(ISP_FORCE_CRASH_DUMP)");
 			isp_fw_dump(isp);
 			isp_reinit(isp);
-			ISP_UNLOCK(isp);
 			retval = 0;
 		}
 		break;
@@ -395,31 +381,25 @@
 		isp->isp_role = nr;
 		/* FALLTHROUGH */
 	case ISP_RESETHBA:
-		ISP_LOCK(isp);
 		isp_reinit(isp);
-		ISP_UNLOCK(isp);
 		retval = 0;
 		break;
 	case ISP_RESCAN:
 		if (IS_FC(isp)) {
-			ISP_LOCK(isp);
 			if (isp_fc_runstate(isp, 5 * 1000000)) {
 				retval = EIO;
 			} else {
 				retval = 0;
 			}
-			ISP_UNLOCK(isp);
 		}
 		break;
 	case ISP_FC_LIP:
 		if (IS_FC(isp)) {
-			ISP_LOCK(isp);
 			if (isp_control(isp, ISPCTL_SEND_LIP, 0)) {
 				retval = EIO;
 			} else {
 				retval = 0;
 			}
-			ISP_UNLOCK(isp);
 		}
 		break;
 	case ISP_FC_GETDINFO:
@@ -434,7 +414,6 @@
 			retval = EINVAL;
 			break;
 		}
-		ISP_LOCK(isp);
 		lp = &FCPARAM(isp)->portdb[ifc->loopid];
 		if (lp->state == FC_PORTDB_STATE_VALID) {
 			ifc->role = lp->roles;
@@ -446,7 +425,6 @@
 		} else {
 			retval = ENODEV;
 		}
-		ISP_UNLOCK(isp);
 		break;
 	}
 	case ISP_GET_STATS:
@@ -457,7 +435,6 @@
 		sp->isp_stat_version = ISP_STATS_VERSION;
 		sp->isp_type = isp->isp_type;
 		sp->isp_revision = isp->isp_revision;
-		ISP_LOCK(isp);
 		sp->isp_stats[ISP_INTCNT] = isp->isp_intcnt;
 		sp->isp_stats[ISP_INTBOGUS] = isp->isp_intbogus;
 		sp->isp_stats[ISP_INTMBOXC] = isp->isp_intmboxc;
@@ -466,12 +443,10 @@
 		sp->isp_stats[ISP_FPHCCMCPLT] = isp->isp_fphccmplt;
 		sp->isp_stats[ISP_RSCCHIWAT] = isp->isp_rscchiwater;
 		sp->isp_stats[ISP_FPCCHIWAT] = isp->isp_fpcchiwater;
-		ISP_UNLOCK(isp);
 		retval = 0;
 		break;
 	}
 	case ISP_CLR_STATS:
-		ISP_LOCK(isp);
 		isp->isp_intcnt = 0;
 		isp->isp_intbogus = 0;
 		isp->isp_intmboxc = 0;
@@ -480,7 +455,6 @@
 		isp->isp_fphccmplt = 0;
 		isp->isp_rscchiwater = 0;
 		isp->isp_fpcchiwater = 0;
-		ISP_UNLOCK(isp);
 		retval = 0;
 		break;
 	case ISP_FC_GETHINFO:
@@ -641,12 +615,10 @@
 			break;
 		}
 		if (retval == 0) {
-			ISP_LOCK(isp);
 			if (needmarker) {
 				isp->isp_sendmarker |= 1;
 			}
 			retval = isp_control(isp, ISPCTL_RUN_MBOXCMD, &mbs);
-			ISP_UNLOCK(isp);
 			if (retval)
 				retval = EIO;
 		}
@@ -655,6 +627,9 @@
 	default:
 		break;
 	}
+#if __FreeBSD_version < 500000  
+	splx(s);
+#endif
 	return (retval);
 }
 
@@ -1176,9 +1151,7 @@
 		ccb->ccb_h.status = CAM_REQ_CMP_ERR;
 		rls_lun_statep(isp, tptr);
 		isp->isp_osinfo.leact[seq] = 0;
-		ISPLOCK_2_CAMLOCK(isp);
 		xpt_done(ccb);
-		CAMLOCK_2_ISPLOCK(isp);
 		return;
 	} else {
 		isp_prt(isp, ISP_LOGTDEBUG0,
@@ -1191,9 +1164,7 @@
 		xpt_print(ccb->ccb_h.path, lfmt, "en");
 		rls_lun_statep(isp, tptr);
 		isp->isp_osinfo.leact[seq] = 0;
-		ISPLOCK_2_CAMLOCK(isp);
 		xpt_done(ccb);
-		CAMLOCK_2_ISPLOCK(isp);
 		return;
 	}
 
@@ -1213,9 +1184,7 @@
 	destroy_lun_state(isp, tptr);
 	ccb->ccb_h.status = CAM_REQ_CMP;
 	isp->isp_osinfo.leact[seq] = 0;
-	ISPLOCK_2_CAMLOCK(isp);
 	xpt_done(ccb);
-	CAMLOCK_2_ISPLOCK(isp);
 	if (are_any_luns_enabled(isp, XS_CHANNEL(ccb)) == 0) {
 		int bus = XS_CHANNEL(ccb);
 		av = bus << 31;
@@ -1494,9 +1463,7 @@
 	isp_destroy_tgt_handle(isp, handle);
 
 out:
-	ISPLOCK_2_CAMLOCK(isp);
 	xpt_done(ccb);
-	CAMLOCK_2_ISPLOCK(isp);
 }
 
 static void
@@ -1561,13 +1528,11 @@
 static void
 isp_complete_ctio(union ccb *ccb)
 {
-	ISPLOCK_2_CAMLOCK(isp);
 	if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_INPROG) {
 		ccb->ccb_h.status |= CAM_REQ_CMP;
 	}
 	ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
 	xpt_done(ccb);
-	CAMLOCK_2_ISPLOCK(isp);
 }
 
 /*
@@ -1800,7 +1765,6 @@
 	atp->last_xframt = 0;
 	atp->bytes_xfered = 0;
 	atp->state = ATPD_STATE_CAM;
-	ISPLOCK_2_CAMLOCK(siP);
 	xpt_done((union ccb*)atiop);
 
 	isp_prt(isp, ISP_LOGTDEBUG0,
@@ -2004,7 +1968,6 @@
 			tgt = xpt_path_target_id(path);
 			if (tgt >= 0) {
 				sdp += cam_sim_bus(sim);
-				ISP_LOCK(isp);
 				nflags = sdp->isp_devparam[tgt].nvrm_flags;
 #ifndef	ISP_TARGET_MODE
 				nflags &= DPARM_SAFE_DFLT;
@@ -2021,7 +1984,6 @@
 				(void) isp_control(isp,
 				    ISPCTL_UPDATE_PARAMS, NULL);
 				sdp->isp_devparam[tgt].goal_flags = oflags;
-				ISP_UNLOCK(isp);
 			}
 		}
 		break;
@@ -2038,11 +2000,9 @@
 	uint32_t isr;
 	uint16_t sema, mbox;
 
-	ISP_LOCK(isp);
 	if (ISP_READ_ISR(isp, &isr, &sema, &mbox)) {
 		isp_intr(isp, isr, sema, mbox);
 	}
-	ISP_UNLOCK(isp);
 }
 
 
@@ -2058,7 +2018,6 @@
 	 * to kill a command that's already dead by getting it's handle and
 	 * and seeing whether it's still alive.
 	 */
-	ISP_LOCK(isp);
 	handle = isp_find_handle(isp, xs);
 	if (handle) {
 		uint32_t isr;
@@ -2067,14 +2026,12 @@
 		if (XS_CMD_DONE_P(xs)) {
 			isp_prt(isp, ISP_LOGDEBUG1,
 			    "watchdog found done cmd (handle 0x%x)", handle);
-			ISP_UNLOCK(isp);
 			return (1);;
 		}
 
 		if (XS_CMD_WDOG_P(xs)) {
 			isp_prt(isp, ISP_LOGDEBUG2,
 			    "recursive watchdog (handle 0x%x)", handle);
-			ISP_UNLOCK(isp);
 			return (1);
 		}
 
@@ -2085,9 +2042,7 @@
 		if (XS_CMD_DONE_P(xs)) {
 			isp_prt(isp, ISP_LOGDEBUG2,
 			    "watchdog cleanup for handle 0x%x", handle);
-			ISPLOCK_2_CAMLOCK(isp);
 			xpt_done((union ccb *) xs);
-			CAMLOCK_2_ISPLOCK(isp);
 		} else if (XS_CMD_GRACE_P(xs)) {
 			/*
 			 * Make sure the command is *really* dead before we
@@ -2106,19 +2061,15 @@
 			    "watchdog timeout for handle 0x%x\n", handle);
 			XS_SETERR(xs, CAM_CMD_TIMEOUT);
 			XS_CMD_C_WDOG(xs);
-			ISPLOCK_2_CAMLOCK(isp);
 			isp_done(xs);
-			CAMLOCK_2_ISPLOCK(isp);
 		} else {
 			XS_CMD_C_WDOG(xs);
 			xs->ccb_h.timeout_ch = timeout(isp_watchdog, xs, hz);
 			XS_CMD_S_GRACE(xs);
 			isp->isp_sendmarker |= 1 << XS_CHANNEL(xs);
 		}
-		ISP_UNLOCK(isp);
 		return (1);
 	}
-	ISP_UNLOCK(isp);
 	return (0);
 }
 
@@ -2143,7 +2094,6 @@
 isp_make_here(ispsoftc_t *isp, int tgt)
 {
 	union ccb *ccb;
-	ISPLOCK_2_CAMLOCK(mpt);
 	/*
 	 * Allocate a CCB, create a wildcard path for this bus,
 	 * and schedule a rescan.
@@ -2151,31 +2101,26 @@
 	ccb = xpt_alloc_ccb_nowait();
 	if (ccb == NULL) {
 		isp_prt(isp, ISP_LOGWARN, "unable to alloc CCB for rescan");
-		CAMLOCK_2_ISPLOCK(mpt);
 		return;
 	}
 	if (xpt_create_path(&ccb->ccb_h.path, xpt_periph,
 	    cam_sim_path(isp->isp_sim), tgt, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
-		CAMLOCK_2_ISPLOCK(mpt);
 		isp_prt(isp, ISP_LOGWARN, "unable to create path for rescan");
 		xpt_free_ccb(ccb);
 		return;
 	}
 	xpt_rescan(ccb);
-	CAMLOCK_2_ISPLOCK(mpt);
 }
 
 static void
 isp_make_gone(ispsoftc_t *isp, int tgt)
 {
 	struct cam_path *tp;
-	ISPLOCK_2_CAMLOCK(isp);
 	if (xpt_create_path(&tp, NULL, cam_sim_path(isp->isp_sim), tgt,
 	    CAM_LUN_WILDCARD) == CAM_REQ_CMP) {
 		xpt_async(AC_LOST_DEVICE, tp, NULL);
 		xpt_free_path(tp);
 	}
-	CAMLOCK_2_ISPLOCK(isp);
 }
 #else
 #define	isp_make_here(isp, tgt)	do { ; } while (0)
@@ -2201,7 +2146,6 @@
 	int dbidx, tgt, more_to_do = 0;
 
 	isp_prt(isp, ISP_LOGDEBUG0, "GDT timer expired");
-	ISP_LOCK(isp);
 	for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
 		lp = &FCPARAM(isp)->portdb[dbidx];
 
@@ -2234,7 +2178,6 @@
 		    "stopping Gone Device Timer");
 		isp->isp_osinfo.gdt_running = 0;
 	}
-	ISP_UNLOCK(isp);
 }
 
 /*
@@ -2254,7 +2197,6 @@
 	int dbidx, tgt;
 
 	isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "Loop Down Timer expired");
-	ISP_LOCK(isp);
 
 	/*
 	 * Notify to the OS all targets who we now consider have departed.
@@ -2298,16 +2240,7 @@
 	 * to notice that fact (or make it false).
 	 */
 	isp->isp_osinfo.loop_down_time = isp->isp_osinfo.loop_down_limit+1;
-#if __FreeBSD_version < 500000  
 	wakeup(&isp->isp_osinfo.kproc);
-#else
-#ifdef	ISP_SMPLOCK
-	cv_signal(&isp->isp_osinfo.kthread_cv);
-#else
-	wakeup(&isp->isp_osinfo.kthread_cv);
-#endif
-#endif
-	ISP_UNLOCK(isp);
 }
 
 static void
@@ -2316,16 +2249,10 @@
 	ispsoftc_t *isp = arg;
 	int slp = 0;
 #if __FreeBSD_version < 500000  
-        int s;
-
-        s = splcam();
+        int s = splcam();
 #else
-#ifdef	ISP_SMPLOCK
-	mtx_lock(&isp->isp_lock);
-#else
 	mtx_lock(&Giant);
 #endif
-#endif
 	/*
 	 * The first loop is for our usage where we have yet to have
 	 * gotten good fibre channel state.
@@ -2399,24 +2326,11 @@
 		if (wasfrozen && isp->isp_osinfo.simqfrozen == 0) {
 			isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
 			    "isp_kthread: releasing simq");
-			ISPLOCK_2_CAMLOCK(isp);
 			xpt_release_simq(isp->isp_sim, 1);
-			CAMLOCK_2_ISPLOCK(isp);
 		}
 		isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
 		    "isp_kthread: sleep time %d", slp);
-#if __FreeBSD_version < 500000  
-		tsleep(&isp->isp_osinfo.kproc, PRIBIO, "ispf",
-		    slp * hz);
-#else
-#ifdef	ISP_SMPLOCK
-		cv_timed_wait(&isp->isp_osinfo.kthread_cv, &isp->isp_lock,
-		    slp * hz);
-#else
-		(void) tsleep(&isp->isp_osinfo.kthread_cv, PRIBIO, "ispf",
-		    slp * hz);
-#endif
-#endif
+		tsleep(&isp->isp_osinfo.kproc, PRIBIO, "ispf", slp * hz);
 		/*
 		 * If slp is zero, we're waking up for the first time after
 		 * things have been okay. In this case, we set a deferral state
@@ -2432,6 +2346,11 @@
 			    (isp->isp_osinfo.hysteresis * hz));
 		}
 	}
+#if __FreeBSD_version < 500000  
+	splx(s);
+#else
+	mtx_unlock(&Giant);
+#endif
 }
 
 static void
@@ -2448,10 +2367,8 @@
 	ccb->ccb_h.sim_priv.entries[1].ptr = isp;
 	if (isp->isp_state != ISP_RUNSTATE &&
 	    ccb->ccb_h.func_code == XPT_SCSI_IO) {
-		CAMLOCK_2_ISPLOCK(isp);
 		isp_init(isp);
 		if (isp->isp_state != ISP_INITSTATE) {
-			ISP_UNLOCK(isp);
 			/*
 			 * Lie. Say it was a selection timeout.
 			 */
@@ -2461,7 +2378,6 @@
 			return;
 		}
 		isp->isp_state = ISP_RUNSTATE;
-		ISPLOCK_2_CAMLOCK(isp);
 	}
 	isp_prt(isp, ISP_LOGDEBUG2, "isp_action code %x", ccb->ccb_h.func_code);
 
@@ -2492,12 +2408,10 @@
 		}
 #endif
 		((struct ccb_scsiio *) ccb)->scsi_status = SCSI_STATUS_OK;
-		CAMLOCK_2_ISPLOCK(isp);
 		error = isp_start((XS_T *) ccb);
 		switch (error) {
 		case CMD_QUEUED:
 			XS_CMD_S_CLEAR(ccb);
-			ISPLOCK_2_CAMLOCK(isp);
 			ccb->ccb_h.status |= CAM_SIM_QUEUED;
 			if (ccb->ccb_h.timeout != CAM_TIME_INFINITY) {
 				int ms = ccb->ccb_h.timeout;
@@ -2532,7 +2446,6 @@
 				ccb->ccb_h.status =
 				    CAM_SEL_TIMEOUT|CAM_DEV_QFRZN;
 				xpt_freeze_devq(ccb->ccb_h.path, 1);
-				ISPLOCK_2_CAMLOCK(isp);
 				xpt_done(ccb);
 				break;
 			}
@@ -2541,7 +2454,6 @@
 			/*
 			 * Otherwise, retry in a while.
 			 */
-			ISPLOCK_2_CAMLOCK(isp);
 			cam_freeze_devq(ccb->ccb_h.path);
 			cam_release_devq(ccb->ccb_h.path,
 			    RELSIM_RELEASE_AFTER_TIMEOUT, 0, 1000, 0);
@@ -2549,7 +2461,6 @@
 			xpt_done(ccb);
 			break;
 		case CMD_EAGAIN:
-			ISPLOCK_2_CAMLOCK(isp);
 			cam_freeze_devq(ccb->ccb_h.path);
 			cam_release_devq(ccb->ccb_h.path,
 			    RELSIM_RELEASE_AFTER_TIMEOUT, 0, 250, 0);
@@ -2557,10 +2468,8 @@
 			break;
 		case CMD_COMPLETE:
 			isp_done((struct ccb_scsiio *) ccb);
-			ISPLOCK_2_CAMLOCK(isp);
 			break;
 		default:
-			ISPLOCK_2_CAMLOCK(isp);
 			isp_prt(isp, ISP_LOGERR,
 			    "What's this? 0x%x at %d in file %s",
 			    error, __LINE__, __FILE__);
@@ -2573,10 +2482,8 @@
 	case XPT_EN_LUN:		/* Enable LUN as a target */
 	{
 		int seq, i;
-		CAMLOCK_2_ISPLOCK(isp);
 		seq = isp_en_lun(isp, ccb);
 		if (seq < 0) {
-			ISPLOCK_2_CAMLOCK(isp);
 			xpt_done(ccb);
 			break;
 		}
@@ -2588,7 +2495,6 @@
 			}
 			DELAY(1000);
 		}
-		ISPLOCK_2_CAMLOCK(isp);
 		break;
 	}
 	case XPT_NOTIFY_ACK:		/* recycle notify ack */
@@ -2606,7 +2512,6 @@
 		ccb->ccb_h.sim_priv.entries[1].ptr = isp;
 		ccb->ccb_h.flags = 0;
 
-		CAMLOCK_2_ISPLOCK(isp);
 		if (ccb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO) {
 			/*
 			 * Note that the command itself may not be done-
@@ -2630,14 +2535,11 @@
 		}
 		rls_lun_statep(isp, tptr);
 		ccb->ccb_h.status = CAM_REQ_INPROG;
-		ISPLOCK_2_CAMLOCK(isp);
 		break;
 	}
 	case XPT_CONT_TARGET_IO:
 	{
-		CAMLOCK_2_ISPLOCK(isp);
 		isp_target_start_ctio(isp, ccb);
-		ISPLOCK_2_CAMLOCK(isp);
 		break;
 	}
 #endif
@@ -2647,9 +2549,7 @@
 		tgt = ccb->ccb_h.target_id;
 		tgt |= (bus << 16);
 
-		CAMLOCK_2_ISPLOCK(isp);
 		error = isp_control(isp, ISPCTL_RESET_DEV, &tgt);
-		ISPLOCK_2_CAMLOCK(isp);
 		if (error) {
 			ccb->ccb_h.status = CAM_REQ_CMP_ERR;
 		} else {
@@ -2660,7 +2560,6 @@
 	case XPT_ABORT:			/* Abort the specified CCB */
 	{
 		union ccb *accb = ccb->cab.abort_ccb;
-		CAMLOCK_2_ISPLOCK(isp);
 		switch (accb->ccb_h.func_code) {
 #ifdef	ISP_TARGET_MODE
 		case XPT_ACCEPT_TARGET_IO:
@@ -2684,7 +2583,6 @@
 			ccb->ccb_h.status = CAM_REQ_INVALID;
 			break;
 		}
-		ISPLOCK_2_CAMLOCK(isp);
 		xpt_done(ccb);
 		break;
 	}
@@ -2701,7 +2599,6 @@
 			break;
 		}
 		tgt = cts->ccb_h.target_id;
-		CAMLOCK_2_ISPLOCK(isp);
 		if (IS_SCSI(isp)) {
 #ifndef	CAM_NEW_TRAN_CODE
 			sdparam *sdp = isp->isp_param;
@@ -2771,7 +2668,6 @@
 			uint16_t *dptr;
 
 			if (spi->valid == 0 && scsi->valid == 0) {
-				ISPLOCK_2_CAMLOCK(isp);
 				ccb->ccb_h.status = CAM_REQ_CMP;
 				xpt_done(ccb);
 				break;
@@ -2834,14 +2730,12 @@
 			sdp->isp_devparam[tgt].dev_update = 1;
 			isp->isp_update |= (1 << bus);
 		}
-		ISPLOCK_2_CAMLOCK(isp);
 		ccb->ccb_h.status = CAM_REQ_CMP;
 		xpt_done(ccb);
 		break;
 	case XPT_GET_TRAN_SETTINGS:
 		cts = &ccb->cts;
 		tgt = cts->ccb_h.target_id;
-		CAMLOCK_2_ISPLOCK(isp);
 		if (IS_FC(isp)) {
 #ifndef	CAM_NEW_TRAN_CODE
 			/*
@@ -2978,7 +2872,6 @@
 			    IS_CURRENT_SETTINGS(cts)? "ACTIVE" : "NVRAM",
 			    bus, tgt, cts->ccb_h.target_lun, dval, oval, pval);
 		}
-		ISPLOCK_2_CAMLOCK(isp);
 		ccb->ccb_h.status = CAM_REQ_CMP;
 		xpt_done(ccb);
 		break;
@@ -3019,9 +2912,7 @@
 #endif
 	case XPT_RESET_BUS:		/* Reset the specified bus */
 		bus = cam_sim_bus(sim);
-		CAMLOCK_2_ISPLOCK(isp);
 		error = isp_control(isp, ISPCTL_RESET_BUS, &bus);
-		ISPLOCK_2_CAMLOCK(isp);
 		if (error)
 			ccb->ccb_h.status = CAM_REQ_CMP_ERR;
 		else {
@@ -3154,9 +3045,7 @@
 			    "finished command on borrowed time");
 		}
 		XS_CMD_S_CLEAR(sccb);
-		ISPLOCK_2_CAMLOCK(isp);
 		xpt_done((union ccb *) sccb);
-		CAMLOCK_2_ISPLOCK(isp);
 	}
 }
 
@@ -3192,18 +3081,15 @@
 		bus = (tgt >> 16) & 0xffff;
 		tgt &= 0xffff;
 		sdp += bus;
-		ISPLOCK_2_CAMLOCK(isp);
 		if (xpt_create_path(&tmppath, NULL,
 		    cam_sim_path(bus? isp->isp_sim2 : isp->isp_sim),
 		    tgt, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
-			CAMLOCK_2_ISPLOCK(isp);
 			isp_prt(isp, ISP_LOGWARN,
 			    "isp_async cannot make temp path for %d.%d",
 			    tgt, bus);
 			rv = -1;
 			break;
 		}
-		CAMLOCK_2_ISPLOCK(isp);
 		flags = sdp->isp_devparam[tgt].actv_flags;
 #ifdef	CAM_NEW_TRAN_CODE
 		cts.type = CTS_TYPE_CURRENT_SETTINGS;
@@ -3259,10 +3145,8 @@
 		    bus, tgt, sdp->isp_devparam[tgt].actv_period,
 		    sdp->isp_devparam[tgt].actv_offset, flags);
 		xpt_setup_ccb(&cts.ccb_h, tmppath, 1);
-		ISPLOCK_2_CAMLOCK(isp);
 		xpt_async(AC_TRANSFER_NEG, tmppath, &cts);
 		xpt_free_path(tmppath);
-		CAMLOCK_2_ISPLOCK(isp);
 		break;
 	}
 	case ISPASYNC_BUS_RESET:
@@ -3270,13 +3154,9 @@
 		isp_prt(isp, ISP_LOGINFO, "SCSI bus reset on bus %d detected",
 		    bus);
 		if (bus > 0 && isp->isp_path2) {
-			ISPLOCK_2_CAMLOCK(isp);
 			xpt_async(AC_BUS_RESET, isp->isp_path2, NULL);
-			CAMLOCK_2_ISPLOCK(isp);
 		} else if (isp->isp_path) {
-			ISPLOCK_2_CAMLOCK(isp);
 			xpt_async(AC_BUS_RESET, isp->isp_path, NULL);
-			CAMLOCK_2_ISPLOCK(isp);
 		}
 		break;
 	case ISPASYNC_LIP:
@@ -3486,15 +3366,7 @@
 		}
 		isp_prt(isp, ISP_LOGINFO, msg);
 		isp_freeze_loopdown(isp, msg);
-#if __FreeBSD_version < 500000  
 		wakeup(&isp->isp_osinfo.kproc);
-#else
-#ifdef	ISP_SMPLOCK
-		cv_signal(&isp->isp_osinfo.kthread_cv);
-#else
-		wakeup(&isp->isp_osinfo.kthread_cv);
-#endif
-#endif
 		break;
 	}
 #ifdef	ISP_TARGET_MODE

==== //depot/projects/mjexp/sys/dev/isp/isp_freebsd.h#12 (text+ko) ====

@@ -84,18 +84,12 @@
 #define	ISP_SBUS_SUPPORTED	0
 #endif
 
-#define	HANDLE_LOOPSTATE_IN_OUTER_LAYERS	1
-/* #define	ISP_SMPLOCK			1 */
 
 #if __FreeBSD_version < 500000  
 #define	ISP_IFLAGS	INTR_TYPE_CAM
 #else
-#ifdef	ISP_SMPLOCK
-#define	ISP_IFLAGS	INTR_TYPE_CAM | INTR_ENTROPY | INTR_MPSAFE
-#else
 #define	ISP_IFLAGS	INTR_TYPE_CAM | INTR_ENTROPY
 #endif
-#endif
 
 #if __FreeBSD_version < 700000
 typedef void ispfwfunc(int, int, int, void **);
@@ -170,7 +164,6 @@
 #if __FreeBSD_version >= 500000  
 	const struct firmware *	fw;
 	struct mtx		lock;
-	struct cv		kthread_cv;
 	union {
 		struct {
 			char wwnn[17];
@@ -203,27 +196,6 @@
  * Locking macros...
  */
 
-#ifdef	ISP_SMPLOCK
-#define	ISP_LOCK(x)		mtx_lock(&(x)->isp_lock)
-#define	ISP_UNLOCK(x)		mtx_unlock(&(x)->isp_lock)
-#define	ISPLOCK_2_CAMLOCK(isp)	\
-	mtx_unlock(&(isp)->isp_lock); mtx_lock(&Giant)
-#define	CAMLOCK_2_ISPLOCK(isp)	\
-	mtx_unlock(&Giant); mtx_lock(&(isp)->isp_lock)
-#else
-#if __FreeBSD_version < 500000
-#define	ISP_LOCK(x)		do { } while (0)
-#define	ISP_UNLOCK(x)		do { } while (0)
-#define	ISPLOCK_2_CAMLOCK(isp)	do { } while (0)
-#define	CAMLOCK_2_ISPLOCK(isp)	do { } while (0)
-#else
-#define	ISP_LOCK(x)		GIANT_REQUIRED
-#define	ISP_UNLOCK(x)		do { } while (0)
-#define	ISPLOCK_2_CAMLOCK(isp)	do { } while (0)
-#define	CAMLOCK_2_ISPLOCK(isp)	GIANT_REQUIRED
-#endif
-#endif
-
 /*
  * Required Macros/Defines
  */
@@ -495,7 +467,7 @@
 int isp_mstohz(int);
 
 /*
- * Platform specific defines
+ * Platform Version specific defines
  */
 #if __FreeBSD_version < 500000  
 #define	BUS_DMA_ROOTARG(x)	NULL
@@ -512,6 +484,7 @@
 	bus_dma_tag_create(a, b, c, d, e, f, g, h, i, j, k, \
 	busdma_lock_mutex, &Giant, z)
 #endif
+
 #if __FreeBSD_version < 700031
 #define	isp_setup_intr(d, i, f, U, if, ifa, hp)	\
 	bus_setup_intr(d, i, f, if, ifa, hp)
@@ -519,6 +492,15 @@
 #define	isp_setup_intr	bus_setup_intr
 #endif
 
+#if __FreeBSD_version < 500000
+#define	isp_sim_alloc	cam_sim_alloc
+#elif	__FreeBSD_version < 700037
+#define	isp_sim_alloc	cam_sim_alloc
+#else
+#define	isp_sim_alloc(a, b, c, d, e, f, g, h)	\
+	cam_sim_alloc(a, b, c, d, e, &Giant, f, g, h)
+#endif
+
 /* Should be BUS_SPACE_MAXSIZE, but MAXPHYS is larger than BUS_SPACE_MAXSIZE */
 #define ISP_NSEGS ((MAXPHYS / PAGE_SIZE) + 1)  
 

==== //depot/projects/mjexp/sys/dev/isp/isp_pci.c#22 (text+ko) ====

@@ -1203,29 +1203,24 @@
 	/*
 	 * Make sure we're in reset state.
 	 */
-	ISP_LOCK(isp);
 	isp_reset(isp);
 	if (isp->isp_state != ISP_RESETSTATE) {
-		ISP_UNLOCK(isp);
 		goto bad;
 	}
 	isp_init(isp);
 	if (isp->isp_role != ISP_ROLE_NONE && isp->isp_state != ISP_INITSTATE) {
 		isp_uninit(isp);
-		ISP_UNLOCK(isp);
 		goto bad;
 	}
 	isp_attach(isp);
 	if (isp->isp_role != ISP_ROLE_NONE && isp->isp_state != ISP_RUNSTATE) {
 		isp_uninit(isp);
-		ISP_UNLOCK(isp);
 		goto bad;
 	}
 	/*
 	 * XXXX: Here is where we might unload the f/w module
 	 * XXXX: (or decrease the reference count to it).
 	 */
-	ISP_UNLOCK(isp);
 
 	return (0);
 
@@ -1295,14 +1290,12 @@
 	uint32_t isr;
 	uint16_t sema, mbox;
 
-	ISP_LOCK(isp);
 	isp->isp_intcnt++;
 	if (ISP_READ_ISR(isp, &isr, &sema, &mbox) == 0) {
 		isp->isp_intbogus++;
 	} else {
 		isp_intr(isp, isr, sema, mbox);
 	}
-	ISP_UNLOCK(isp);
 }
 
 
@@ -1771,12 +1764,10 @@
 	}
 #endif
 
-	ISP_UNLOCK(isp);
 	if (isp_dma_tag_create(BUS_DMA_ROOTARG(pcs->pci_dev), 1, slim, llim,
 	    hlim, NULL, NULL, BUS_SPACE_MAXSIZE, ISP_NSEGS, slim, 0,
 	    &pcs->dmat)) {
 		isp_prt(isp, ISP_LOGERR, "could not create master dma tag");
-		ISP_LOCK(isp);
 		return (1);
 	}
 
@@ -1785,7 +1776,6 @@
 	isp->isp_xflist = (XS_T **) malloc(len, M_DEVBUF, M_WAITOK | M_ZERO);
 	if (isp->isp_xflist == NULL) {
 		isp_prt(isp, ISP_LOGERR, "cannot alloc xflist array");
-		ISP_LOCK(isp);
 		return (1);
 	}
 #ifdef	ISP_TARGET_MODE
@@ -1793,7 +1783,6 @@
 	isp->isp_tgtlist = (void **) malloc(len, M_DEVBUF, M_WAITOK | M_ZERO);
 	if (isp->isp_tgtlist == NULL) {
 		isp_prt(isp, ISP_LOGERR, "cannot alloc tgtlist array");
-		ISP_LOCK(isp);
 		return (1);
 	}
 #endif
@@ -1805,7 +1794,6 @@
 #ifdef	ISP_TARGET_MODE
 		free(isp->isp_tgtlist, M_DEVBUF);
 #endif
-		ISP_LOCK(isp);
 		return (1);
 	}
 
@@ -1832,7 +1820,6 @@
 #ifdef	ISP_TARGET_MODE
 		free(isp->isp_tgtlist, M_DEVBUF);
 #endif

>>> TRUNCATED FOR MAIL (1000 lines) <<<


More information about the p4-projects mailing list