Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Dec 2015 09:16:05 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r292745 - head/sys/dev/isp
Message-ID:  <201512260916.tBQ9G5BN058578@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Sat Dec 26 09:16:05 2015
New Revision: 292745
URL: https://svnweb.freebsd.org/changeset/base/292745

Log:
  Use single DMA tag for scratch areas of all virtual ports.

Modified:
  head/sys/dev/isp/isp_freebsd.h
  head/sys/dev/isp/isp_pci.c

Modified: head/sys/dev/isp/isp_freebsd.h
==============================================================================
--- head/sys/dev/isp/isp_freebsd.h	Sat Dec 26 09:09:49 2015	(r292744)
+++ head/sys/dev/isp/isp_freebsd.h	Sat Dec 26 09:16:05 2015	(r292745)
@@ -225,8 +225,7 @@ struct isp_fc {
 	struct cam_path *path;
 	struct ispsoftc *isp;
 	struct proc *kproc;
-	bus_dma_tag_t tdmat;
-	bus_dmamap_t tdmap;
+	bus_dmamap_t scmap;
 	uint64_t def_wwpn;
 	uint64_t def_wwnn;
 	time_t loop_down_time;
@@ -285,13 +284,14 @@ struct isposinfo {
 	const struct firmware *	fw;
 
 	/*
-	 * DMA related sdtuff
+	 * DMA related stuff
 	 */
 	struct resource *	regs;
 	struct resource *	regs2;
 	bus_dma_tag_t		dmat;
 	bus_dma_tag_t		cdmat;
 	bus_dmamap_t		cdmap;
+	bus_dma_tag_t		scdmat;
 
 	/*
 	 * Command and transaction related related stuff
@@ -409,7 +409,7 @@ switch (type) {							\
 case SYNC_SFORDEV:						\
 {								\
 	struct isp_fc *fc = ISP_FC_PC(isp, chan);		\
-	bus_dmamap_sync(fc->tdmat, fc->tdmap,			\
+	bus_dmamap_sync(isp->isp_osinfo.scdmat, fc->scmap,	\
 	   BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);		\
 	break;							\
 }								\
@@ -421,7 +421,7 @@ case SYNC_REQUEST:						\
 case SYNC_SFORCPU:						\
 {								\
 	struct isp_fc *fc = ISP_FC_PC(isp, chan);		\
-	bus_dmamap_sync(fc->tdmat, fc->tdmap,			\
+	bus_dmamap_sync(isp->isp_osinfo.scdmat, fc->scmap,	\
 	   BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);	\
 	break;							\
 }								\
@@ -443,7 +443,7 @@ switch (type) {							\
 case SYNC_SFORDEV:						\
 {								\
 	struct isp_fc *fc = ISP_FC_PC(isp, chan);		\
-	bus_dmamap_sync(fc->tdmat, fc->tdmap,			\
+	bus_dmamap_sync(isp->isp_osinfo.scdmat, fc->scmap,	\
 	   BUS_DMASYNC_PREWRITE);				\
 	break;							\
 }								\
@@ -454,7 +454,7 @@ case SYNC_REQUEST:						\
 case SYNC_SFORCPU:						\
 {								\
 	struct isp_fc *fc = ISP_FC_PC(isp, chan);		\
-	bus_dmamap_sync(fc->tdmat, fc->tdmap,			\
+	bus_dmamap_sync(isp->isp_osinfo.scdmat, fc->scmap,	\
 	   BUS_DMASYNC_POSTWRITE);				\
 	break;							\
 }								\

Modified: head/sys/dev/isp/isp_pci.c
==============================================================================
--- head/sys/dev/isp/isp_pci.c	Sat Dec 26 09:09:49 2015	(r292744)
+++ head/sys/dev/isp/isp_pci.c	Sat Dec 26 09:16:05 2015	(r292745)
@@ -1604,11 +1604,8 @@ imc1(void *arg, bus_dma_segment_t *segs,
 		imushp->error = error;
 		return;
 	}
-	if (nseg != 1) {
-		imushp->error = EINVAL;
-		return;
-	}
-	isp_prt(imushp->isp, ISP_LOGDEBUG0, "scdma @ 0x%jx/0x%jx", (uintmax_t) segs->ds_addr, (uintmax_t) segs->ds_len);
+	isp_prt(imushp->isp, ISP_LOGDEBUG0, "scdma @ 0x%jx/0x%jx",
+	    (uintmax_t) segs->ds_addr, (uintmax_t) segs->ds_len);
 	FCPARAM(imushp->isp, imushp->chan)->isp_scdma = segs->ds_addr;
 	FCPARAM(imushp->isp, imushp->chan)->isp_scratch = imushp->vbase;
 }
@@ -1735,23 +1732,27 @@ isp_pci_mbxdma(ispsoftc_t *isp)
 	}
 
 	if (IS_FC(isp)) {
+		if (isp_dma_tag_create(isp->isp_osinfo.dmat, 64, slim,
+		    BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL,
+		    ISP_FC_SCRLEN, 1, ISP_FC_SCRLEN, 0, &isp->isp_osinfo.scdmat)) {
+			goto bad;
+		}
 		for (cmap = 0; cmap < isp->isp_nchan; cmap++) {
 			struct isp_fc *fc = ISP_FC_PC(isp, cmap);
-			if (isp_dma_tag_create(isp->isp_osinfo.dmat, 64, slim, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, ISP_FC_SCRLEN, 1, slim, 0, &fc->tdmat)) {
-				goto bad;
-			}
-			if (bus_dmamem_alloc(fc->tdmat, (void **)&base, BUS_DMA_NOWAIT | BUS_DMA_COHERENT, &fc->tdmap) != 0) {
-				bus_dma_tag_destroy(fc->tdmat);
+			if (bus_dmamem_alloc(isp->isp_osinfo.scdmat,
+			    (void **)&base, BUS_DMA_NOWAIT | BUS_DMA_COHERENT,
+			    &fc->scmap) != 0) {
 				goto bad;
 			}
 			im.isp = isp;
 			im.chan = cmap;
 			im.vbase = base;
 			im.error = 0;
-			bus_dmamap_load(fc->tdmat, fc->tdmap, base, ISP_FC_SCRLEN, imc1, &im, 0);
+			bus_dmamap_load(isp->isp_osinfo.scdmat, fc->scmap,
+			    base, ISP_FC_SCRLEN, imc1, &im, 0);
 			if (im.error) {
-				bus_dmamem_free(fc->tdmat, base, fc->tdmap);
-				bus_dma_tag_destroy(fc->tdmat);
+				bus_dmamem_free(isp->isp_osinfo.scdmat,
+				    base, fc->scmap);
 				goto bad;
 			}
 			if (!IS_2100(isp)) {
@@ -1794,16 +1795,18 @@ isp_pci_mbxdma(ispsoftc_t *isp)
 	return (0);
 
 bad:
-	while (--cmap >= 0) {
-		struct isp_fc *fc = ISP_FC_PC(isp, cmap);
-		bus_dmamap_unload(fc->tdmat, fc->tdmap);
-		bus_dmamem_free(fc->tdmat, base, fc->tdmap);
-		bus_dma_tag_destroy(fc->tdmat);
-		while (fc->nexus_free_list) {
-			struct isp_nexus *n = fc->nexus_free_list;
-			fc->nexus_free_list = n->next;
-			free(n, M_DEVBUF);
+	if (IS_FC(isp)) {
+		while (--cmap >= 0) {
+			struct isp_fc *fc = ISP_FC_PC(isp, cmap);
+			bus_dmamap_unload(isp->isp_osinfo.scdmat, fc->scmap);
+			bus_dmamem_free(isp->isp_osinfo.scdmat, base, fc->scmap);
+			while (fc->nexus_free_list) {
+				struct isp_nexus *n = fc->nexus_free_list;
+				fc->nexus_free_list = n->next;
+				free(n, M_DEVBUF);
+			}
 		}
+		bus_dma_tag_destroy(isp->isp_osinfo.scdmat);
 	}
 	if (isp->isp_rquest_dma != 0)
 		bus_dmamap_unload(isp->isp_osinfo.cdmat, isp->isp_osinfo.cdmap);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201512260916.tBQ9G5BN058578>