From owner-p4-projects@FreeBSD.ORG Mon Apr 2 01:01:22 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 3470F16A405; Mon, 2 Apr 2007 01:01:22 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 03AC916A402 for ; Mon, 2 Apr 2007 01:01:22 +0000 (UTC) (envelope-from mjacob@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id E83B013C448 for ; Mon, 2 Apr 2007 01:01:21 +0000 (UTC) (envelope-from mjacob@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l3211Lcc073468 for ; Mon, 2 Apr 2007 01:01:21 GMT (envelope-from mjacob@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l3211LZ6073461 for perforce@freebsd.org; Mon, 2 Apr 2007 01:01:21 GMT (envelope-from mjacob@freebsd.org) Date: Mon, 2 Apr 2007 01:01:21 GMT Message-Id: <200704020101.l3211LZ6073461@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to mjacob@freebsd.org using -f From: Matt Jacob To: Perforce Change Reviews Cc: Subject: PERFORCE change 117150 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2007 01:01:22 -0000 http://perforce.freebsd.org/chv.cgi?CH=117150 Change 117150 by mjacob@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 +/* + * 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 ==== //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 {