[Midnightbsd-cvs] src [7825] trunk/sys/dev/isci/isci_io_request.c: Don' t call bus_dmamap_load in CAM_DIR_NONE case, since there is nothing

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Tue Sep 6 20:01:22 EDT 2016


Revision: 7825
          http://svnweb.midnightbsd.org/src/?rev=7825
Author:   laffer1
Date:     2016-09-06 20:01:22 -0400 (Tue, 06 Sep 2016)
Log Message:
-----------
Don't call bus_dmamap_load in CAM_DIR_NONE case, since there is nothing
to map, and technically this isn't allowed.

Functionally, it works OK (at least on x86) to call bus_dmamap_load with
a NULL data pointer and zero length, so this is primarily for correctness
and consistency with other drivers.

While here, remove check in isci_io_request_construct for nseg==0.
Previously, bus_dmamap_load would pass nseg==1, even for case where
buffer is NULL and length = 0, which allowed CAM_DIR_NONE CCBs
to get processed.  This check is not correct though, and needed to be
removed both for the changes elsewhere in this patch, as well as jeff's
preliminary bus_dmamap_load_ccb patch (which uncovered all of this in
the first place).

Obtained from: FreeBSD SVN 244128

Modified Paths:
--------------
    trunk/sys/dev/isci/isci_io_request.c

Modified: trunk/sys/dev/isci/isci_io_request.c
===================================================================
--- trunk/sys/dev/isci/isci_io_request.c	2016-09-06 23:59:42 UTC (rev 7824)
+++ trunk/sys/dev/isci/isci_io_request.c	2016-09-07 00:01:22 UTC (rev 7825)
@@ -670,8 +670,7 @@
 	io_request->sge = seg;
 	ccb = io_request->ccb;
 
-	/* XXX More cleanup is needed here */
-	if ((nseg == 0) || (error != 0)) {
+	if (error != 0) {
 		ccb->ccb_h.status = CAM_REQ_INVALID;
 		xpt_done(ccb);
 		return;
@@ -757,18 +756,21 @@
 		panic("Unexpected CAM_DATA_PHYS flag!  flags = 0x%x\n",
 		    ccb->ccb_h.flags);
 
-	error = bus_dmamap_load(io_request->parent.dma_tag,
-	    io_request->parent.dma_map, csio->data_ptr, csio->dxfer_len,
-	    isci_io_request_construct, io_request, 0x0);
+	if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
+		error = bus_dmamap_load(io_request->parent.dma_tag,
+		    io_request->parent.dma_map, csio->data_ptr, csio->dxfer_len,
+		    isci_io_request_construct, io_request, 0x0);
 
-	/* A resource shortage from BUSDMA will be automatically
-	 * continued at a later point, pushing the CCB processing
-	 * forward, which will in turn unfreeze the simq.
-	 */
-	if (error == EINPROGRESS) {
-		xpt_freeze_simq(controller->sim, 1);
-		ccb->ccb_h.flags |= CAM_RELEASE_SIMQ;
-	}
+		/* A resource shortage from BUSDMA will be automatically
+		 * continued at a later point, pushing the CCB processing
+		 * forward, which will in turn unfreeze the simq.
+		 */
+		if (error == EINPROGRESS) {
+			xpt_freeze_simq(controller->sim, 1);
+			ccb->ccb_h.flags |= CAM_RELEASE_SIMQ;
+		}
+	} else
+		isci_io_request_construct(io_request, NULL, 0, 0);
 }
 
 void



More information about the Midnightbsd-cvs mailing list