svn commit: r251939 - in stable/9/sys: kern sys

Marius Strobl marius at FreeBSD.org
Tue Jun 18 14:20:14 UTC 2013


Author: marius
Date: Tue Jun 18 14:20:14 2013
New Revision: 251939
URL: http://svnweb.freebsd.org/changeset/base/251939

Log:
  MFC: r248804
  
  deferal -> deferral
  
  MFC: r248891
  
  Pass correct parameter to CTR5() in bus_dmamap_load_uio.
  
  MFC: r248892
  
  Do not add 1 to nsegs before passing to CTR5(), since nsegs
  has already been incremented before these calls.
  
  MFC: r248893
  
  Add CTR5() to bus_dmamap_load_ccb, similar to other bus_dmamap_load_*
  functions.
  
  MFC: r248896
  
  Add bus_dmamap_load_bio for non-CAM disk drivers that wish to enable
  unmapped I/O.
  
  MFC: r249025
  
  Add support for XPT_CONT_TARGET_IO CCBs in _bus_dmamap_load_ccb().
  
  Declare CCB types in their respective switch blocks.
  
  MFC: r249538
  
  Some compilers issue a warning when wider integer is casted to narrow
  pointer.  Supposedly shut down the warning by casting through
  uintptr_t.
  
  MFC: r251221
  
  Move an assertion to the right spot; only bus_dmamap_load_mbuf(9)
  requires a pkthdr being present but that's not the case for either
  _bus_dmamap_load_mbuf_sg() or bus_dmamap_load_mbuf_sg(9).

Modified:
  stable/9/sys/kern/subr_bus_dma.c
  stable/9/sys/sys/bus_dma.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/sys/   (props changed)

Modified: stable/9/sys/kern/subr_bus_dma.c
==============================================================================
--- stable/9/sys/kern/subr_bus_dma.c	Tue Jun 18 13:38:10 2013	(r251938)
+++ stable/9/sys/kern/subr_bus_dma.c	Tue Jun 18 14:20:14 2013	(r251939)
@@ -104,8 +104,6 @@ _bus_dmamap_load_mbuf_sg(bus_dma_tag_t d
 	struct mbuf *m;
 	int error;
 
-	M_ASSERTPKTHDR(m0);
-
 	error = 0;
 	for (m = m0; m != NULL && error == 0; m = m->m_next) {
 		if (m->m_len > 0) {
@@ -158,8 +156,6 @@ static int
 _bus_dmamap_load_ccb(bus_dma_tag_t dmat, bus_dmamap_t map, union ccb *ccb,
 		    int *nsegs, int flags)
 {
-	struct ccb_ataio *ataio;
-	struct ccb_scsiio *csio;
 	struct ccb_hdr *ccb_h;
 	void *data_ptr;
 	int error;
@@ -169,18 +165,33 @@ _bus_dmamap_load_ccb(bus_dma_tag_t dmat,
 	error = 0;
 	ccb_h = &ccb->ccb_h;
 	switch (ccb_h->func_code) {
-	case XPT_SCSI_IO:
+	case XPT_SCSI_IO: {
+		struct ccb_scsiio *csio;
+
 		csio = &ccb->csio;
 		data_ptr = csio->data_ptr;
 		dxfer_len = csio->dxfer_len;
 		sglist_cnt = csio->sglist_cnt;
 		break;
-	case XPT_ATA_IO:
+	}
+	case XPT_CONT_TARGET_IO: {
+		struct ccb_scsiio *ctio;
+
+		ctio = &ccb->ctio;
+		data_ptr = ctio->data_ptr;
+		dxfer_len = ctio->dxfer_len;
+		sglist_cnt = ctio->sglist_cnt;
+		break;
+	}
+	case XPT_ATA_IO: {
+		struct ccb_ataio *ataio;
+
 		ataio = &ccb->ataio;
 		data_ptr = ataio->data_ptr;
 		dxfer_len = ataio->dxfer_len;
 		sglist_cnt = 0;
 		break;
+	}
 	default:
 		panic("_bus_dmamap_load_ccb: Unsupported func code %d",
 		    ccb_h->func_code);
@@ -282,7 +293,7 @@ bus_dmamap_load(bus_dma_tag_t dmat, bus_
 	nsegs++;
 
 	CTR5(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d nsegs %d",
-	    __func__, dmat, flags, error, nsegs + 1);
+	    __func__, dmat, flags, error, nsegs);
 
 	if (error == EINPROGRESS)
 		return (error);
@@ -295,7 +306,7 @@ bus_dmamap_load(bus_dma_tag_t dmat, bus_
 
 	/*
 	 * Return ENOMEM to the caller so that it can pass it up the stack.
-	 * This error only happens when NOWAIT is set, so deferal is disabled.
+	 * This error only happens when NOWAIT is set, so deferral is disabled.
 	 */
 	if (error == ENOMEM)
 		return (error);
@@ -310,6 +321,8 @@ bus_dmamap_load_mbuf(bus_dma_tag_t dmat,
 	bus_dma_segment_t *segs;
 	int nsegs, error;
 
+	M_ASSERTPKTHDR(m0);
+
 	flags |= BUS_DMA_NOWAIT;
 	nsegs = -1;
 	error = _bus_dmamap_load_mbuf_sg(dmat, map, m0, NULL, &nsegs, flags);
@@ -359,7 +372,7 @@ bus_dmamap_load_uio(bus_dma_tag_t dmat, 
 		(*callback)(callback_arg, segs, nsegs, uio->uio_resid, error);
 
 	CTR5(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d nsegs %d",
-	    __func__, dmat, dmat, error, nsegs + 1);
+	    __func__, dmat, flags, error, nsegs);
 	return (error);
 }
 
@@ -386,6 +399,10 @@ bus_dmamap_load_ccb(bus_dma_tag_t dmat, 
 	nsegs = -1;
 	error = _bus_dmamap_load_ccb(dmat, map, ccb, &nsegs, flags);
 	nsegs++;
+
+	CTR5(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d nsegs %d",
+	    __func__, dmat, flags, error, nsegs);
+
 	if (error == EINPROGRESS)
 		return (error);
 
@@ -396,7 +413,46 @@ bus_dmamap_load_ccb(bus_dma_tag_t dmat, 
 		(*callback)(callback_arg, segs, nsegs, error);
 	/*
 	 * Return ENOMEM to the caller so that it can pass it up the stack.
-	 * This error only happens when NOWAIT is set, so deferal is disabled.
+	 * This error only happens when NOWAIT is set, so deferral is disabled.
+	 */
+	if (error == ENOMEM)
+		return (error);
+
+	return (0);
+}
+
+int
+bus_dmamap_load_bio(bus_dma_tag_t dmat, bus_dmamap_t map, struct bio *bio,
+		    bus_dmamap_callback_t *callback, void *callback_arg,
+		    int flags)
+{
+	bus_dma_segment_t *segs;
+	struct memdesc mem;
+	int error;
+	int nsegs;
+
+	if ((flags & BUS_DMA_NOWAIT) == 0) {
+		mem = memdesc_bio(bio);
+		_bus_dmamap_waitok(dmat, map, &mem, callback, callback_arg);
+	}
+	nsegs = -1;
+	error = _bus_dmamap_load_bio(dmat, map, bio, &nsegs, flags);
+	nsegs++;
+
+	CTR5(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d nsegs %d",
+	    __func__, dmat, flags, error, nsegs);
+
+	if (error == EINPROGRESS)
+		return (error);
+
+	segs = _bus_dmamap_complete(dmat, map, NULL, nsegs, error);
+	if (error)
+		(*callback)(callback_arg, segs, 0, error);
+	else
+		(*callback)(callback_arg, segs, nsegs, error);
+	/*
+	 * Return ENOMEM to the caller so that it can pass it up the stack.
+	 * This error only happens when NOWAIT is set, so deferral is disabled.
 	 */
 	if (error == ENOMEM)
 		return (error);
@@ -455,7 +511,7 @@ bus_dmamap_load_mem(bus_dma_tag_t dmat, 
 	nsegs++;
 
 	CTR5(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d nsegs %d",
-	    __func__, dmat, flags, error, nsegs + 1);
+	    __func__, dmat, flags, error, nsegs);
 
 	if (error == EINPROGRESS)
 		return (error);
@@ -468,7 +524,7 @@ bus_dmamap_load_mem(bus_dma_tag_t dmat, 
 
 	/*
 	 * Return ENOMEM to the caller so that it can pass it up the stack.
-	 * This error only happens when NOWAIT is set, so deferal is disabled.
+	 * This error only happens when NOWAIT is set, so deferral is disabled.
 	 */
 	if (error == ENOMEM)
 		return (error);

Modified: stable/9/sys/sys/bus_dma.h
==============================================================================
--- stable/9/sys/sys/bus_dma.h	Tue Jun 18 13:38:10 2013	(r251938)
+++ stable/9/sys/sys/bus_dma.h	Tue Jun 18 14:20:14 2013	(r251939)
@@ -233,6 +233,13 @@ int bus_dmamap_load_ccb(bus_dma_tag_t dm
 			int flags);
 
 /*
+ * Like bus_dmamap_load but for bios.
+ */
+int bus_dmamap_load_bio(bus_dma_tag_t dmat, bus_dmamap_t map, struct bio *bio,
+			bus_dmamap_callback_t *callback, void *callback_arg,
+			int flags);
+
+/*
  * Loads any memory descriptor.
  */
 int bus_dmamap_load_mem(bus_dma_tag_t dmat, bus_dmamap_t map,


More information about the svn-src-all mailing list