PERFORCE change 117150 for review

Matt Jacob mjacob at FreeBSD.org
Mon Apr 2 01:01:22 UTC 2007


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

Change 117150 by mjacob at mjexp on 2007/04/02 01:00:59

	
	Temporarily desupport simultaneous target and initiator mode.
	
	When the linux port changes were imported which split the
	target command list to be separate from the initiator command
	list and the handle format changed to encode a type in the handle
	the implications to the function isp_handle_index (which only
	the NetBSD/OpenBSD/FreeBSD ports use) were overlooked.
	
	The fault is twofold: first, the index into the DMA maps
	in  isp_pci is wrong because a target command handle with
	the type bit left in place caused a bad index (and panic)
	into dma map. Secondly, the assumption of the array
	of DMA maps in either PCS or SBUS attachment structures is
	that there is a linear mapping between handle index and
	DMA map index. This can no longer be true if there are
	overlapping index spaces for initiator mode and target
	mode commands.
	
	These changes bandaid around the problem by forcing us
	to not have simultaneous dual roles and doing the appropriate
	masking to make sure things are indexed correctly. A longer
	term fix is being devloped.

Affected files ...

.. //depot/projects/mjexp/sys/conf/NOTES#15 edit
.. //depot/projects/mjexp/sys/dev/isp/isp_freebsd.c#14 edit
.. //depot/projects/mjexp/sys/dev/isp/isp_freebsd.h#10 edit
.. //depot/projects/mjexp/sys/dev/isp/isp_library.c#6 edit
.. //depot/projects/mjexp/sys/dev/isp/isp_library.h#6 edit
.. //depot/projects/mjexp/sys/dev/isp/isp_pci.c#20 edit
.. //depot/projects/mjexp/sys/dev/isp/isp_sbus.c#9 edit

Differences ...

==== //depot/projects/mjexp/sys/conf/NOTES#15 (text+ko) ====

@@ -1521,9 +1521,13 @@
 #
 options 	ISP_TARGET_MODE=1
 #
-#	ISP_DEFAULT_ROLES	-	default role (none, target, init, both)
+#	ISP_DEFAULT_ROLES	-	default role
+#		none=0
+#		target=1
+#		initiator=2
+#		both=3			(not supported currently)
 #
-options 	ISP_DEFAULT_ROLES=3
+options 	ISP_DEFAULT_ROLES=2
 
 # Options used in dev/sym/ (Symbios SCSI driver).
 #options 	SYM_SETUP_LP_PROBE_MAP	#-Low Priority Probe Map (bits)

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

@@ -382,6 +382,14 @@
 			retval = EINVAL;
 			break;
 		}
+		/*
+		 * XXX: Current
+		 */
+		if (nr == ISP_ROLE_BOTH) {
+			isp_prt(isp, ISP_LOGERR, "dual roles not supported");
+			retval = EINVAL;
+			break;
+		}
 		*(int *)addr = isp->isp_role;
 		isp->isp_role = nr;
 		/* FALLTHROUGH */
@@ -1133,7 +1141,7 @@
 static void
 isp_ledone(ispsoftc_t *isp, lun_entry_t *lep)
 {
-	const char lfmt[] = "now %sabled for target mode";
+	const char lfmt[] = "now %sabled for target mode\n";
 	union ccb *ccb;
 	uint32_t seq;
 	tstate_t *tptr;

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

@@ -532,4 +532,10 @@
 
 #include <dev/isp/isp_library.h>
 
+/*
+ * XXX: Temp
+ */
+#if	ISP_DEFAULT_ROLES == ISP_ROLE_BOTH
+#error	"Dual Role Temporarily Unsupported"
+#endif
 #endif	/* _ISP_FREEBSD_H */

==== //depot/projects/mjexp/sys/dev/isp/isp_library.c#6 (text) ====

@@ -1499,12 +1499,12 @@
 void *
 isp_find_xs_tgt(ispsoftc_t *isp, uint32_t handle)
 {
-	if (handle == 0 || (handle & 0x8000) == 0 ||
-	    (handle & 0x7fff) > isp->isp_maxcmds) {
+	if (handle == 0 || IS_TARGET_HANDLE(handle) == 0 ||
+	    (handle & ISP_HANDLE_MASK) > isp->isp_maxcmds) {
 		isp_prt(isp, ISP_LOGERR, "bad handle in isp_find_xs_tgt");
 		return (NULL);
 	} else {
-		return (isp->isp_tgtlist[(handle & 0x7fff) - 1]);
+		return (isp->isp_tgtlist[(handle & ISP_HANDLE_MASK) - 1]);
 	}
 }
 
@@ -1515,7 +1515,7 @@
 	if (xs != NULL) {
 		for (i = 0; i < isp->isp_maxcmds; i++) {
 			if (isp->isp_tgtlist[i] == xs) {
-				return ((i+1) & 0x7fff);
+				return ((i+1) & ISP_HANDLE_MASK);
 			}
 		}
 	}
@@ -1525,12 +1525,12 @@
 void
 isp_destroy_tgt_handle(ispsoftc_t *isp, uint32_t handle)
 {
-	if (handle == 0 || (handle & 0x8000) == 0 ||
-	    (handle & 0x7fff) > isp->isp_maxcmds) {
+	if (handle == 0 || IS_TARGET_HANDLE(handle) == 0 ||
+	    (handle & ISP_HANDLE_MASK) > isp->isp_maxcmds) {
 		isp_prt(isp, ISP_LOGERR,
 		    "bad handle in isp_destroy_tgt_handle");
 	} else {
-		isp->isp_tgtlist[(handle & 0x7fff) - 1] = NULL;
+		isp->isp_tgtlist[(handle & ISP_HANDLE_MASK) - 1] = NULL;
 	}
 }
 

==== //depot/projects/mjexp/sys/dev/isp/isp_library.h#6 (text) ====

@@ -128,6 +128,8 @@
 extern void isp_get_ct_hdr(ispsoftc_t *isp, ct_hdr_t *, ct_hdr_t *);
 extern void isp_put_ct_hdr(ispsoftc_t *isp, ct_hdr_t *, ct_hdr_t *);
 
+#define	ISP_HANDLE_MASK		0x7fff
+
 #ifdef	ISP_TARGET_MODE
 #if	defined(__NetBSD__) || defined(__OpenBSD__)
 #include <dev/ic/isp_target.h>

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

@@ -1994,7 +1994,7 @@
 	cto->ct_scsi_status = 0;
 
 	pcs = (struct isp_pcisoftc *)isp;
-	dp = &pcs->dmaps[isp_handle_index(handle)];
+	dp = &pcs->dmaps[isp_handle_index(handle & ISP_HANDLE_MASK)];
 	if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
 		bus_dmamap_sync(pcs->dmat, *dp, BUS_DMASYNC_PREREAD);
 	} else {
@@ -2388,7 +2388,7 @@
 	isp = mp->isp;
 	rq = mp->rq;
 	pcs = (struct isp_pcisoftc *)mp->isp;
-	dp = &pcs->dmaps[isp_handle_index(rq->req_handle)];
+	dp = &pcs->dmaps[isp_handle_index(rq->req_handle & ISP_HANDLE_MASK)];
 	nxti = *mp->nxtip;
 
 	if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
@@ -2494,7 +2494,7 @@
 	isp = mp->isp;
 	rq = mp->rq;
 	pcs = (struct isp_pcisoftc *)mp->isp;
-	dp = &pcs->dmaps[isp_handle_index(rq->req_handle)];
+	dp = &pcs->dmaps[isp_handle_index(rq->req_handle & ISP_HANDLE_MASK)];
 	nxti = *mp->nxtip;
 
 	if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
@@ -2628,7 +2628,7 @@
 	isp = mp->isp;
 	rq = mp->rq;
 	pcs = (struct isp_pcisoftc *)mp->isp;
-	dp = &pcs->dmaps[isp_handle_index(rq->req_handle)];
+	dp = &pcs->dmaps[isp_handle_index(rq->req_handle & ISP_HANDLE_MASK)];
 	nxti = *mp->nxtip;
 
 	if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
@@ -2795,7 +2795,8 @@
 	if ((csio->ccb_h.flags & CAM_SCATTER_VALID) == 0) {
 		if ((csio->ccb_h.flags & CAM_DATA_PHYS) == 0) {
 			int error, s;
-			dp = &pcs->dmaps[isp_handle_index(rq->req_handle)];
+			dp = &pcs->dmaps[isp_handle_index(
+			    rq->req_handle & ISP_HANDLE_MASK)];
 			s = splsoftvm();
 			error = bus_dmamap_load(pcs->dmat, *dp,
 			    csio->data_ptr, csio->dxfer_len, eptr, mp, 0);
@@ -2880,7 +2881,8 @@
 isp_pci_dmateardown(ispsoftc_t *isp, XS_T *xs, uint32_t handle)
 {
 	struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp;
-	bus_dmamap_t *dp = &pcs->dmaps[isp_handle_index(handle)];
+	bus_dmamap_t *dp;
+	dp = &pcs->dmaps[isp_handle_index(handle & ISP_HANDLE_MASK)];
 	if ((xs->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
 		bus_dmamap_sync(pcs->dmat, *dp, BUS_DMASYNC_POSTREAD);
 	} else {

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

@@ -624,7 +624,7 @@
 	isp = mp->isp;
 	rq = mp->rq;
 	sbs = (struct isp_sbussoftc *)mp->isp;
-	dp = &sbs->dmaps[isp_handle_index(rq->req_handle)];
+	dp = &sbs->dmaps[isp_handle_index(rq->req_handle & ISP_HANDLE_MASK)];
 	nxti = *mp->nxtip;
 
 	if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
@@ -735,7 +735,8 @@
 	if ((csio->ccb_h.flags & CAM_SCATTER_VALID) == 0) {
 		if ((csio->ccb_h.flags & CAM_DATA_PHYS) == 0) {
 			int error, s;
-			dp = &sbs->dmaps[isp_handle_index(rq->req_handle)];
+			dp = &sbs->dmaps[isp_handle_index(
+			    rq->req_handle & ISP_HANDLE_MASK)];
 			s = splsoftvm();
 			error = bus_dmamap_load(sbs->dmat, *dp,
 			    csio->data_ptr, csio->dxfer_len, eptr, mp, 0);
@@ -809,7 +810,8 @@
 isp_sbus_dmateardown(ispsoftc_t *isp, XS_T *xs, uint32_t handle)
 {
 	struct isp_sbussoftc *sbs = (struct isp_sbussoftc *)isp;
-	bus_dmamap_t *dp = &sbs->dmaps[isp_handle_index(handle)];
+	bus_dmamap_t *dp;
+	dp = &sbs->dmaps[isp_handle_index(handle & ISP_HANDLE_MASK)];
 	if ((xs->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
 		bus_dmamap_sync(sbs->dmat, *dp, BUS_DMASYNC_POSTREAD);
 	} else {


More information about the p4-projects mailing list