[Midnightbsd-cvs] src [9888] trunk/sys/dev/isp: sync with freebsd-9-stable

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Thu May 24 09:22:07 EDT 2018


Revision: 9888
          http://svnweb.midnightbsd.org/src/?rev=9888
Author:   laffer1
Date:     2018-05-24 09:22:06 -0400 (Thu, 24 May 2018)
Log Message:
-----------
sync with freebsd-9-stable

Modified Paths:
--------------
    trunk/sys/dev/isp/isp.c
    trunk/sys/dev/isp/isp_freebsd.c
    trunk/sys/dev/isp/isp_pci.c
    trunk/sys/dev/isp/isp_sbus.c
    trunk/sys/dev/isp/ispreg.h

Modified: trunk/sys/dev/isp/isp.c
===================================================================
--- trunk/sys/dev/isp/isp.c	2018-05-24 13:15:39 UTC (rev 9887)
+++ trunk/sys/dev/isp/isp.c	2018-05-24 13:22:06 UTC (rev 9888)
@@ -75,7 +75,6 @@
 static const char fconf[] = "Chan %d PortDB[%d] changed:\n current =(0x%x at 0x%06x 0x%08x%08x 0x%08x%08x)\n database=(0x%x at 0x%06x 0x%08x%08x 0x%08x%08x)";
 static const char notresp[] = "Not RESPONSE in RESPONSE Queue (type 0x%x) @ idx %d (next %d) nlooked %d";
 static const char topology[] = "Chan %d WWPN 0x%08x%08x PortID 0x%06x N-Port Handle %d, Connection '%s'";
-static const char sc4[] = "NVRAM";
 static const char bun[] = "bad underrun (count %d, resid %d, status %s)";
 static const char lipd[] = "Chan %d LIP destroyed %d active commands";
 static const char sacq[] = "unable to acquire scratch area";
@@ -1709,7 +1708,13 @@
 	 *
 	 * NB: for the 2300, ICBOPT_EXTENDED is required.
 	 */
-	if (IS_2200(isp) || IS_23XX(isp)) {
+	if (IS_2100(isp)) {
+		/*
+		 * We can't have Fast Posting any more- we now
+		 * have 32 bit handles.
+		 */
+		icbp->icb_fwoptions &= ~ICBOPT_FAST_POST;
+	} else if (IS_2200(isp) || IS_23XX(isp)) {
 		icbp->icb_fwoptions |= ICBOPT_EXTENDED;
 
 		icbp->icb_xfwoptions = fcp->isp_xfwoptions;
@@ -2327,7 +2332,7 @@
 		goto out;
 	} else if (plp->plogx_status != PLOGX_STATUS_IOCBERR) {
 		isp_prt(isp, ISP_LOGWARN,
-		    "status 0x%x on port login IOCB chanel %d",
+		    "status 0x%x on port login IOCB channel %d",
 		    plp->plogx_status, chan);
 		rval = -1;
 		goto out;
@@ -2583,7 +2588,7 @@
 		}
 		mbs.param[9] = chan;
 	} else {
-		mbs.ibits = 3;
+		mbs.ibitm = 3;
 		mbs.param[1] = loopid << 8;
 		if (nodename) {
 			mbs.param[1] |= 1;
@@ -7357,6 +7362,13 @@
 	ibits |= mbp->ibits;
 	obits |= mbp->obits;
 
+	/*
+	 * Mask any bits that the caller wants us to mask
+	 */
+	ibits &= mbp->ibitm;
+	obits &= mbp->obitm;
+
+
 	if (ibits == 0 && obits == 0) {
 		mbp->param[0] = MBOX_COMMAND_PARAM_ERROR;
 		isp_prt(isp, ISP_LOGERR, "no parameters for 0x%x", opcode);

Modified: trunk/sys/dev/isp/isp_freebsd.c
===================================================================
--- trunk/sys/dev/isp/isp_freebsd.c	2018-05-24 13:15:39 UTC (rev 9887)
+++ trunk/sys/dev/isp/isp_freebsd.c	2018-05-24 13:22:06 UTC (rev 9888)
@@ -56,7 +56,6 @@
 int isp_gone_device_time = 30;	/* grace time before reporting device lost */
 int isp_autoconfig = 1;		/* automatically attach/detach devices */
 static const char prom3[] = "Chan %d PortID 0x%06x Departed from Target %u because of %s";
-static const char rqo[] = "%s: Request Queue Overflow\n";
 
 static void isp_freeze_loopdown(ispsoftc_t *, int, char *);
 static d_ioctl_t ispioctl;
@@ -2146,7 +2145,8 @@
 
 	qe = isp_getrqentry(isp);
 	if (qe == NULL) {
-		xpt_print(ccb->ccb_h.path, rqo, __func__);
+		xpt_print(ccb->ccb_h.path,
+		    "%s: Request Queue Overflow\n", __func__);
 		(void) timeout(isp_refire_putback_atio, ccb, 10);
 		return;
 	}
@@ -4556,7 +4556,8 @@
 		isp_prt(isp, ISP_LOGWARN, "Chan %d unable to alloc CCB for rescan", chan);
 		return;
 	}
-	if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, cam_sim_path(fc->sim), tgt, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
+	if (xpt_create_path(&ccb->ccb_h.path, NULL, cam_sim_path(fc->sim),
+	    tgt, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
 		isp_prt(isp, ISP_LOGWARN, "unable to create path for rescan");
 		xpt_free_ccb(ccb);
 		return;
@@ -5446,11 +5447,16 @@
 		cpi->max_target = ISP_MAX_TARGETS(isp) - 1;
 		cpi->max_lun = ISP_MAX_LUNS(isp) - 1;
 		cpi->bus_id = cam_sim_bus(sim);
+		if (isp->isp_osinfo.sixtyfourbit)
+			cpi->maxio = (ISP_NSEG64_MAX - 1) * PAGE_SIZE;
+		else
+			cpi->maxio = (ISP_NSEG_MAX - 1) * PAGE_SIZE;
+
 		bus = cam_sim_bus(xpt_path_sim(cpi->ccb_h.path));
 		if (IS_FC(isp)) {
 			fcparam *fcp = FCPARAM(isp, bus);
 
-			cpi->hba_misc = PIM_NOBUSRESET;
+			cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED;
 
 			/*
 			 * Because our loop ID can shift from time to time,
@@ -5480,7 +5486,7 @@
 		} else {
 			sdparam *sdp = SDPARAM(isp, bus);
 			cpi->hba_inquiry = PI_SDTR_ABLE|PI_TAG_ABLE|PI_WIDE_16;
-			cpi->hba_misc = 0;
+			cpi->hba_misc = PIM_UNMAPPED;
 			cpi->initiator_id = sdp->isp_initiator_id;
 			cpi->base_transfer_speed = 3300;
 			cpi->transport = XPORT_SPI;

Modified: trunk/sys/dev/isp/isp_pci.c
===================================================================
--- trunk/sys/dev/isp/isp_pci.c	2018-05-24 13:15:39 UTC (rev 9887)
+++ trunk/sys/dev/isp/isp_pci.c	2018-05-24 13:22:06 UTC (rev 9888)
@@ -706,13 +706,10 @@
 	pcs->irq = pcs->regs = NULL;
 	pcs->rgd = pcs->rtp = pcs->iqd = 0;
 
-	cmd = pci_read_config(dev, PCIR_COMMAND, 2);
-	if (cmd & m1) {
-		pcs->rtp = (m1 == PCIM_CMD_MEMEN)? SYS_RES_MEMORY : SYS_RES_IOPORT;
-		pcs->rgd = (m1 == PCIM_CMD_MEMEN)? MEM_MAP_REG : IO_MAP_REG;
-		pcs->regs = bus_alloc_resource_any(dev, pcs->rtp, &pcs->rgd, RF_ACTIVE);
-	}
-	if (pcs->regs == NULL && (cmd & m2)) {
+	pcs->rtp = (m1 == PCIM_CMD_MEMEN)? SYS_RES_MEMORY : SYS_RES_IOPORT;
+	pcs->rgd = (m1 == PCIM_CMD_MEMEN)? MEM_MAP_REG : IO_MAP_REG;
+	pcs->regs = bus_alloc_resource_any(dev, pcs->rtp, &pcs->rgd, RF_ACTIVE);
+	if (pcs->regs == NULL) {
 		pcs->rtp = (m2 == PCIM_CMD_MEMEN)? SYS_RES_MEMORY : SYS_RES_IOPORT;
 		pcs->rgd = (m2 == PCIM_CMD_MEMEN)? MEM_MAP_REG : IO_MAP_REG;
 		pcs->regs = bus_alloc_resource_any(dev, pcs->rtp, &pcs->rgd, RF_ACTIVE);
@@ -891,6 +888,7 @@
 	/*
 	 * Make sure that SERR, PERR, WRITE INVALIDATE and BUSMASTER are set.
 	 */
+	cmd = pci_read_config(dev, PCIR_COMMAND, 2);
 	cmd |= PCIM_CMD_SEREN | PCIM_CMD_PERRESPEN | PCIM_CMD_BUSMASTEREN | PCIM_CMD_INVEN;
 	if (IS_2300(isp)) {	/* per QLogic errata */
 		cmd &= ~PCIM_CMD_INVEN;
@@ -1922,6 +1920,7 @@
 	mush_t mush, *mp;
 	void (*eptr)(void *, bus_dma_segment_t *, int, int);
 	void (*eptr2)(void *, bus_dma_segment_t *, int, bus_size_t, int);
+	int error;
 
 	mp = &mush;
 	mp->isp = isp;
@@ -1942,70 +1941,17 @@
 	}
 
 
-	if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE || (csio->dxfer_len == 0)) {
-		(*eptr)(mp, NULL, 0, 0);
-	} else if ((csio->ccb_h.flags & CAM_SCATTER_VALID) == 0) {
-		if ((csio->ccb_h.flags & CAM_DATA_PHYS) == 0) {
-			int error;
-			error = bus_dmamap_load(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap, csio->data_ptr, csio->dxfer_len, eptr, mp, 0);
-#if 0
-			xpt_print(csio->ccb_h.path, "%s: bus_dmamap_load " "ptr %p len %d returned %d\n", __func__, csio->data_ptr, csio->dxfer_len, error);
-#endif
-
-			if (error == EINPROGRESS) {
-				bus_dmamap_unload(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap);
-				mp->error = EINVAL;
-				isp_prt(isp, ISP_LOGERR, "deferred dma allocation not supported");
-			} else if (error && mp->error == 0) {
+	error = bus_dmamap_load_ccb(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap,
+	    (union ccb *)csio, eptr, mp, 0);
+	if (error == EINPROGRESS) {
+		bus_dmamap_unload(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap);
+		mp->error = EINVAL;
+		isp_prt(isp, ISP_LOGERR, "deferred dma allocation not supported");
+	} else if (error && mp->error == 0) {
 #ifdef	DIAGNOSTIC
-				isp_prt(isp, ISP_LOGERR, "error %d in dma mapping code", error);
+		isp_prt(isp, ISP_LOGERR, "error %d in dma mapping code", error);
 #endif
-				mp->error = error;
-			}
-		} else {
-			/* Pointer to physical buffer */
-			struct bus_dma_segment seg;
-			seg.ds_addr = (bus_addr_t)(vm_offset_t)csio->data_ptr;
-			seg.ds_len = csio->dxfer_len;
-			(*eptr)(mp, &seg, 1, 0);
-		}
-	} else {
-		struct bus_dma_segment *segs;
-
-		if ((csio->ccb_h.flags & CAM_DATA_PHYS) != 0) {
-			isp_prt(isp, ISP_LOGERR, "Physical segment pointers unsupported");
-			mp->error = EINVAL;
-		} else if ((csio->ccb_h.flags & CAM_SG_LIST_PHYS) == 0) {
-			struct uio sguio;
-			int error;
-
-			/*
-			 * We're taking advantage of the fact that
-			 * the pointer/length sizes and layout of the iovec
-			 * structure are the same as the bus_dma_segment
-			 * structure.  This might be a little dangerous,
-			 * but only if they change the structures, which
-			 * seems unlikely.
-			 */
-			KASSERT((sizeof (sguio.uio_iov) == sizeof (csio->data_ptr) &&
-			    sizeof (sguio.uio_iovcnt) >= sizeof (csio->sglist_cnt) &&
-			    sizeof (sguio.uio_resid) >= sizeof (csio->dxfer_len)), ("Ken's assumption failed"));
-			sguio.uio_iov = (struct iovec *)csio->data_ptr;
-			sguio.uio_iovcnt = csio->sglist_cnt;
-			sguio.uio_resid = csio->dxfer_len;
-			sguio.uio_segflg = UIO_SYSSPACE;
-
-			error = bus_dmamap_load_uio(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap, &sguio, eptr2, mp, 0);
-
-			if (error != 0 && mp->error == 0) {
-				isp_prt(isp, ISP_LOGERR, "error %d in dma mapping code", error);
-				mp->error = error;
-			}
-		} else {
-			/* Just use the segments provided */
-			segs = (struct bus_dma_segment *) csio->data_ptr;
-			(*eptr)(mp, segs, csio->sglist_cnt, 0);
-		}
+		mp->error = error;
 	}
 	if (mp->error) {
 		int retval = CMD_COMPLETE;

Modified: trunk/sys/dev/isp/isp_sbus.c
===================================================================
--- trunk/sys/dev/isp/isp_sbus.c	2018-05-24 13:15:39 UTC (rev 9887)
+++ trunk/sys/dev/isp/isp_sbus.c	2018-05-24 13:22:06 UTC (rev 9888)
@@ -635,6 +635,7 @@
 {
 	mush_t mush, *mp;
 	void (*eptr)(void *, bus_dma_segment_t *, int, int);
+	int error;
 
 	mp = &mush;
 	mp->isp = isp;
@@ -645,47 +646,18 @@
 
 	eptr = dma2;
 
-	if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE || (csio->dxfer_len == 0)) {
-		(*eptr)(mp, NULL, 0, 0);
-	} else if ((csio->ccb_h.flags & CAM_SCATTER_VALID) == 0) {
-		if ((csio->ccb_h.flags & CAM_DATA_PHYS) == 0) {
-			int error;
-			error = bus_dmamap_load(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap, csio->data_ptr, csio->dxfer_len, eptr, mp, 0);
-#if 0
-			xpt_print(csio->ccb_h.path, "%s: bus_dmamap_load " "ptr %p len %d returned %d\n", __func__, csio->data_ptr, csio->dxfer_len, error);
-#endif
-
-			if (error == EINPROGRESS) {
-				bus_dmamap_unload(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap);
-				mp->error = EINVAL;
-				isp_prt(isp, ISP_LOGERR, "deferred dma allocation not supported");
-			} else if (error && mp->error == 0) {
+	error = bus_dmamap_load_ccb(isp->isp_osinfo.dmat,
+	    PISP_PCMD(csio)->dmap, (union ccb *)csio, eptr, mp, 0);
+	if (error == EINPROGRESS) {
+		bus_dmamap_unload(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap);
+		mp->error = EINVAL;
+		isp_prt(isp, ISP_LOGERR,
+		    "deferred dma allocation not supported");
+	} else if (error && mp->error == 0) {
 #ifdef	DIAGNOSTIC
-				isp_prt(isp, ISP_LOGERR, "error %d in dma mapping code", error);
+		isp_prt(isp, ISP_LOGERR, "error %d in dma mapping code", error);
 #endif
-				mp->error = error;
-			}
-		} else {
-			/* Pointer to physical buffer */
-			struct bus_dma_segment seg;
-			seg.ds_addr = (bus_addr_t)(vm_offset_t)csio->data_ptr;
-			seg.ds_len = csio->dxfer_len;
-			(*eptr)(mp, &seg, 1, 0);
-		}
-	} else {
-		struct bus_dma_segment *segs;
-
-		if ((csio->ccb_h.flags & CAM_DATA_PHYS) != 0) {
-			isp_prt(isp, ISP_LOGERR, "Physical segment pointers unsupported");
-			mp->error = EINVAL;
-		} else if ((csio->ccb_h.flags & CAM_SG_LIST_PHYS) == 0) {
-			isp_prt(isp, ISP_LOGERR, "Physical SG/LIST Phys segment pointers unsupported");
-			mp->error = EINVAL;
-		} else {
-			/* Just use the segments provided */
-			segs = (struct bus_dma_segment *) csio->data_ptr;
-			(*eptr)(mp, segs, csio->sglist_cnt, 0);
-		}
+		mp->error = error;
 	}
 	if (mp->error) {
 		int retval = CMD_COMPLETE;

Modified: trunk/sys/dev/isp/ispreg.h
===================================================================
--- trunk/sys/dev/isp/ispreg.h	2018-05-24 13:15:39 UTC (rev 9887)
+++ trunk/sys/dev/isp/ispreg.h	2018-05-24 13:22:06 UTC (rev 9888)
@@ -464,8 +464,10 @@
 #define	MBCMD_DEFAULT_TIMEOUT	100000	/* 100 ms */
 typedef struct {
 	uint16_t param[MAX_MAILBOX];
-	uint32_t ibits;
-	uint32_t obits;
+	uint32_t ibits;	/* bits to add for register copyin */
+	uint32_t obits;	/* bits to add for register copyout */
+	uint32_t ibitm;	/* bits to mask for register copyin */
+	uint32_t obitm;	/* bits to mask for register copyout */
 	uint32_t
 		lineno	: 16,
 			: 12,
@@ -475,6 +477,8 @@
 } mbreg_t;
 #define	MBSINIT(mbxp, code, loglev, timo)	\
 	ISP_MEMZERO((mbxp), sizeof (mbreg_t));	\
+	(mbxp)->ibitm = ~0;			\
+	(mbxp)->obitm = ~0;			\
 	(mbxp)->param[0] = code;		\
 	(mbxp)->lineno = __LINE__;		\
 	(mbxp)->func = __func__;		\



More information about the Midnightbsd-cvs mailing list