Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Jul 2017 05:35:29 +0000 (UTC)
From:      "Jason A. Harmening" <jah@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r320528 - in head/sys: amd64/include arm/arm arm/include arm64/arm64 arm64/include dev/aac dev/aacraid dev/bnxt dev/cxgb dev/cxgb/ulp/iw_cxgb dev/hyperv/storvsc dev/mfi dev/tsec dev/xdm...
Message-ID:  <201707010535.v615ZTSY031146@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jah
Date: Sat Jul  1 05:35:29 2017
New Revision: 320528
URL: https://svnweb.freebsd.org/changeset/base/320528

Log:
  Clean up MD pollution of bus_dma.h:
  
  --Remove special-case handling of sparc64 bus_dmamap* functions.
    Replace with a more generic mechanism that allows MD busdma
    implementations to generate inline mapping functions by
    defining WANT_INLINE_DMAMAP in <machine/bus_dma.h>.  This
    is currently useful for sparc64, x86, and arm64, which all
    implement non-load dmamap operations as simple wrappers
    around map objects which may be bus- or device-specific.
  
  --Remove NULL-checked bus_dmamap macros.  Implement the
    equivalent NULL checks in the inlined x86 implementation.
    For non-x86 platforms, these checks are a minor pessimization
    as those platforms do not currently allow NULL maps.  NULL
    maps were originally allowed on arm64, which appears to have
    been the motivation behind adding arm[64]-specific barriers
    to bus_dma.h, but that support was removed in r299463.
  
  --Simplify the internal interface used by the bus_dmamap_load*
    variants and move it to bus_dma_internal.h
  
  --Fix some drivers that directly include sys/bus_dma.h
    despite the recommendations of bus_dma(9)
  
  Reviewed by:	kib (previous revision), marius
  Differential Revision:	https://reviews.freebsd.org/D10729

Added:
  head/sys/sys/bus_dma_internal.h   (contents, props changed)
  head/sys/x86/include/bus_dma.h   (contents, props changed)
Modified:
  head/sys/amd64/include/bus_dma.h
  head/sys/arm/arm/busdma_machdep-v4.c
  head/sys/arm/arm/busdma_machdep-v6.c
  head/sys/arm/include/bus_dma.h
  head/sys/arm64/arm64/busdma_machdep.c
  head/sys/arm64/include/bus_dma.h
  head/sys/arm64/include/bus_dma_impl.h
  head/sys/dev/aac/aac.c
  head/sys/dev/aacraid/aacraid.c
  head/sys/dev/bnxt/bnxt.h
  head/sys/dev/cxgb/cxgb_adapter.h
  head/sys/dev/cxgb/cxgb_main.c
  head/sys/dev/cxgb/cxgb_sge.c
  head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.c
  head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c
  head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cq.c
  head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_dbg.c
  head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_ev.c
  head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_hal.c
  head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_mem.c
  head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
  head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_qp.c
  head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_resource.c
  head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
  head/sys/dev/mfi/mfi.c
  head/sys/dev/mfi/mfi_cam.c
  head/sys/dev/tsec/if_tsec.c
  head/sys/dev/xdma/xdma.c
  head/sys/dev/xen/blkfront/blkfront.c
  head/sys/i386/include/bus_dma.h
  head/sys/mips/include/bus_dma.h
  head/sys/mips/mips/busdma_machdep.c
  head/sys/net/iflib.h
  head/sys/powerpc/include/bus_dma.h
  head/sys/powerpc/powerpc/busdma_machdep.c
  head/sys/riscv/include/bus_dma.h
  head/sys/riscv/riscv/busdma_machdep.c
  head/sys/sparc64/include/bus_dma.h
  head/sys/sys/bus_dma.h
  head/sys/x86/include/busdma_impl.h
  head/sys/x86/iommu/busdma_dmar.c
  head/sys/x86/x86/busdma_bounce.c
  head/sys/x86/x86/busdma_machdep.c

Modified: head/sys/amd64/include/bus_dma.h
==============================================================================
--- head/sys/amd64/include/bus_dma.h	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/amd64/include/bus_dma.h	Sat Jul  1 05:35:29 2017	(r320528)
@@ -29,6 +29,6 @@
 #ifndef _AMD64_BUS_DMA_H_
 #define _AMD64_BUS_DMA_H_
 
-#include <sys/bus_dma.h>
+#include <x86/bus_dma.h> 
 
 #endif /* _AMD64_BUS_DMA_H_ */

Modified: head/sys/arm/arm/busdma_machdep-v4.c
==============================================================================
--- head/sys/arm/arm/busdma_machdep-v4.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/arm/arm/busdma_machdep-v4.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -1008,7 +1008,7 @@ _bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t
 	 * Did we fit?
 	 */
 	if (buflen != 0) {
-		_bus_dmamap_unload(dmat, map);
+		bus_dmamap_unload(dmat, map);
 		return (EFBIG); /* XXX better return value here? */
 	}
 	return (0);
@@ -1129,14 +1129,14 @@ cleanup:
 	 * Did we fit?
 	 */
 	if (buflen != 0) {
-		_bus_dmamap_unload(dmat, map);
+		bus_dmamap_unload(dmat, map);
 		return (EFBIG); /* XXX better return value here? */
 	}
 	return (0);
 }
 
 void
-__bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map, struct memdesc *mem,
+_bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map, struct memdesc *mem,
     bus_dmamap_callback_t *callback, void *callback_arg)
 {
 
@@ -1161,7 +1161,7 @@ _bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t 
  * Release the mapping held by map.
  */
 void
-_bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map)
+bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map)
 {
 	struct bounce_page *bpage;
 	struct bounce_zone *bz;
@@ -1334,7 +1334,7 @@ _bus_dmamap_sync_bp(bus_dma_tag_t dmat, bus_dmamap_t m
 }
 
 void
-_bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op)
+bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op)
 {
 	struct sync_list *sl, *end;
 	int bufaligned;

Modified: head/sys/arm/arm/busdma_machdep-v6.c
==============================================================================
--- head/sys/arm/arm/busdma_machdep-v6.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/arm/arm/busdma_machdep-v6.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -1070,7 +1070,7 @@ _bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t
 	 * Did we fit?
 	 */
 	if (buflen != 0) {
-		_bus_dmamap_unload(dmat, map);
+		bus_dmamap_unload(dmat, map);
 		return (EFBIG); /* XXX better return value here? */
 	}
 	return (0);
@@ -1195,14 +1195,14 @@ cleanup:
 	 * Did we fit?
 	 */
 	if (buflen != 0) {
-		_bus_dmamap_unload(dmat, map);
+		bus_dmamap_unload(dmat, map);
 		return (EFBIG); /* XXX better return value here? */
 	}
 	return (0);
 }
 
 void
-__bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map, struct memdesc *mem,
+_bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map, struct memdesc *mem,
     bus_dmamap_callback_t *callback, void *callback_arg)
 {
 
@@ -1226,7 +1226,7 @@ _bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t 
  * Release the mapping held by map.
  */
 void
-_bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map)
+bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map)
 {
 	struct bounce_page *bpage;
 	struct bounce_zone *bz;
@@ -1326,7 +1326,7 @@ dma_dcache_sync(struct sync_list *sl, bus_dmasync_op_t
 }
 
 void
-_bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op)
+bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op)
 {
 	struct bounce_page *bpage;
 	struct sync_list *sl, *end;

Modified: head/sys/arm/include/bus_dma.h
==============================================================================
--- head/sys/arm/include/bus_dma.h	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/arm/include/bus_dma.h	Sat Jul  1 05:35:29 2017	(r320528)
@@ -67,6 +67,7 @@
 #define _ARM_BUS_DMA_H
 
 #include <sys/bus_dma.h>
+#include <sys/bus_dma_internal.h>
 
 /* Bus Space DMA macros */
 

Modified: head/sys/arm64/arm64/busdma_machdep.c
==============================================================================
--- head/sys/arm64/arm64/busdma_machdep.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/arm64/arm64/busdma_machdep.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -223,133 +223,3 @@ bus_dma_tag_destroy(bus_dma_tag_t dmat)
 	return (tc->impl->tag_destroy(dmat));
 }
 
-/*
- * Allocate a handle for mapping from kva/uva/physical
- * address space into bus device space.
- */
-int
-bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
-{
-	struct bus_dma_tag_common *tc;
-
-	tc = (struct bus_dma_tag_common *)dmat;
-	return (tc->impl->map_create(dmat, flags, mapp));
-}
-
-/*
- * Destroy a handle for mapping from kva/uva/physical
- * address space into bus device space.
- */
-int
-bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map)
-{
-	struct bus_dma_tag_common *tc;
-
-	tc = (struct bus_dma_tag_common *)dmat;
-	return (tc->impl->map_destroy(dmat, map));
-}
-
-
-/*
- * Allocate a piece of memory that can be efficiently mapped into
- * bus device space based on the constraints listed in the dma tag.
- * A dmamap to for use with dmamap_load is also allocated.
- */
-int
-bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
-    bus_dmamap_t *mapp)
-{
-	struct bus_dma_tag_common *tc;
-
-	tc = (struct bus_dma_tag_common *)dmat;
-	return (tc->impl->mem_alloc(dmat, vaddr, flags, mapp));
-}
-
-/*
- * Free a piece of memory and it's allociated dmamap, that was allocated
- * via bus_dmamem_alloc.  Make the same choice for free/contigfree.
- */
-void
-bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map)
-{
-	struct bus_dma_tag_common *tc;
-
-	tc = (struct bus_dma_tag_common *)dmat;
-	tc->impl->mem_free(dmat, vaddr, map);
-}
-
-int
-_bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t buf,
-    bus_size_t buflen, int flags, bus_dma_segment_t *segs, int *segp)
-{
-	struct bus_dma_tag_common *tc;
-
-	tc = (struct bus_dma_tag_common *)dmat;
-	return (tc->impl->load_phys(dmat, map, buf, buflen, flags, segs,
-	    segp));
-}
-
-int
-_bus_dmamap_load_ma(bus_dma_tag_t dmat, bus_dmamap_t map, struct vm_page **ma,
-    bus_size_t tlen, int ma_offs, int flags, bus_dma_segment_t *segs,
-    int *segp)
-{
-	struct bus_dma_tag_common *tc;
-
-	tc = (struct bus_dma_tag_common *)dmat;
-	return (tc->impl->load_ma(dmat, map, ma, tlen, ma_offs, flags,
-	    segs, segp));
-}
-
-int
-_bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
-    bus_size_t buflen, pmap_t pmap, int flags, bus_dma_segment_t *segs,
-    int *segp)
-{
-	struct bus_dma_tag_common *tc;
-
-	tc = (struct bus_dma_tag_common *)dmat;
-	return (tc->impl->load_buffer(dmat, map, buf, buflen, pmap, flags, segs,
-	    segp));
-}
-
-void
-__bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
-    struct memdesc *mem, bus_dmamap_callback_t *callback, void *callback_arg)
-{
-	struct bus_dma_tag_common *tc;
-
-	tc = (struct bus_dma_tag_common *)dmat;
-	tc->impl->map_waitok(dmat, map, mem, callback, callback_arg);
-}
-
-bus_dma_segment_t *
-_bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t map,
-    bus_dma_segment_t *segs, int nsegs, int error)
-{
-	struct bus_dma_tag_common *tc;
-
-	tc = (struct bus_dma_tag_common *)dmat;
-	return (tc->impl->map_complete(dmat, map, segs, nsegs, error));
-}
-
-/*
- * Release the mapping held by map.
- */
-void
-_bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map)
-{
-	struct bus_dma_tag_common *tc;
-
-	tc = (struct bus_dma_tag_common *)dmat;
-	tc->impl->map_unload(dmat, map);
-}
-
-void
-_bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op)
-{
-	struct bus_dma_tag_common *tc;
-
-	tc = (struct bus_dma_tag_common *)dmat;
-	tc->impl->map_sync(dmat, map, op);
-}

Modified: head/sys/arm64/include/bus_dma.h
==============================================================================
--- head/sys/arm64/include/bus_dma.h	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/arm64/include/bus_dma.h	Sat Jul  1 05:35:29 2017	(r320528)
@@ -3,6 +3,139 @@
 #ifndef _MACHINE_BUS_DMA_H_
 #define	_MACHINE_BUS_DMA_H_
 
+#define WANT_INLINE_DMAMAP
 #include <sys/bus_dma.h>
+
+#include <machine/bus_dma_impl.h>
+
+/*
+ * Allocate a handle for mapping from kva/uva/physical
+ * address space into bus device space.
+ */
+static inline int
+bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
+{
+	struct bus_dma_tag_common *tc;
+
+	tc = (struct bus_dma_tag_common *)dmat;
+	return (tc->impl->map_create(dmat, flags, mapp));
+}
+
+/*
+ * Destroy a handle for mapping from kva/uva/physical
+ * address space into bus device space.
+ */
+static inline int
+bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map)
+{
+	struct bus_dma_tag_common *tc;
+
+	tc = (struct bus_dma_tag_common *)dmat;
+	return (tc->impl->map_destroy(dmat, map));
+}
+
+/*
+ * Allocate a piece of memory that can be efficiently mapped into
+ * bus device space based on the constraints listed in the dma tag.
+ * A dmamap to for use with dmamap_load is also allocated.
+ */
+static inline int
+bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
+    bus_dmamap_t *mapp)
+{
+	struct bus_dma_tag_common *tc;
+
+	tc = (struct bus_dma_tag_common *)dmat;
+	return (tc->impl->mem_alloc(dmat, vaddr, flags, mapp));
+}
+
+/*
+ * Free a piece of memory and it's allociated dmamap, that was allocated
+ * via bus_dmamem_alloc.  Make the same choice for free/contigfree.
+ */
+static inline void
+bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map)
+{
+	struct bus_dma_tag_common *tc;
+
+	tc = (struct bus_dma_tag_common *)dmat;
+	tc->impl->mem_free(dmat, vaddr, map);
+}
+
+/*
+ * Release the mapping held by map.
+ */
+static inline void
+bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map)
+{
+	struct bus_dma_tag_common *tc;
+
+	tc = (struct bus_dma_tag_common *)dmat;
+	tc->impl->map_unload(dmat, map);
+}
+
+static inline void
+bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op)
+{
+	struct bus_dma_tag_common *tc;
+
+	tc = (struct bus_dma_tag_common *)dmat;
+	tc->impl->map_sync(dmat, map, op);
+}
+
+static inline int
+_bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t buf,
+    bus_size_t buflen, int flags, bus_dma_segment_t *segs, int *segp)
+{
+	struct bus_dma_tag_common *tc;
+
+	tc = (struct bus_dma_tag_common *)dmat;
+	return (tc->impl->load_phys(dmat, map, buf, buflen, flags, segs,
+	    segp));
+}
+
+static inline int
+_bus_dmamap_load_ma(bus_dma_tag_t dmat, bus_dmamap_t map, struct vm_page **ma,
+    bus_size_t tlen, int ma_offs, int flags, bus_dma_segment_t *segs,
+    int *segp)
+{
+	struct bus_dma_tag_common *tc;
+
+	tc = (struct bus_dma_tag_common *)dmat;
+	return (tc->impl->load_ma(dmat, map, ma, tlen, ma_offs, flags,
+	    segs, segp));
+}
+
+static inline int
+_bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
+    bus_size_t buflen, struct pmap *pmap, int flags, bus_dma_segment_t *segs,
+    int *segp)
+{
+	struct bus_dma_tag_common *tc;
+
+	tc = (struct bus_dma_tag_common *)dmat;
+	return (tc->impl->load_buffer(dmat, map, buf, buflen, pmap, flags, segs,
+	    segp));
+}
+
+static inline void
+_bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
+    struct memdesc *mem, bus_dmamap_callback_t *callback, void *callback_arg)
+{
+	struct bus_dma_tag_common *tc;
+
+	tc = (struct bus_dma_tag_common *)dmat;
+	tc->impl->map_waitok(dmat, map, mem, callback, callback_arg);
+}
+
+static inline bus_dma_segment_t *
+_bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t map,
+    bus_dma_segment_t *segs, int nsegs, int error)
+{
+	struct bus_dma_tag_common *tc;
+
+	tc = (struct bus_dma_tag_common *)dmat;
+	return (tc->impl->map_complete(dmat, map, segs, nsegs, error));
+}
 
 #endif /* !_MACHINE_BUS_DMA_H_ */

Modified: head/sys/arm64/include/bus_dma_impl.h
==============================================================================
--- head/sys/arm64/include/bus_dma_impl.h	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/arm64/include/bus_dma_impl.h	Sat Jul  1 05:35:29 2017	(r320528)
@@ -70,7 +70,7 @@ struct bus_dma_impl {
 	    vm_paddr_t buf, bus_size_t buflen, int flags,
 	    bus_dma_segment_t *segs, int *segp);
 	int (*load_buffer)(bus_dma_tag_t dmat, bus_dmamap_t map,
-	    void *buf, bus_size_t buflen, pmap_t pmap, int flags,
+	    void *buf, bus_size_t buflen, struct pmap *pmap, int flags,
 	    bus_dma_segment_t *segs, int *segp);
 	void (*map_waitok)(bus_dma_tag_t dmat, bus_dmamap_t map,
 	    struct memdesc *mem, bus_dmamap_callback_t *callback,

Modified: head/sys/dev/aac/aac.c
==============================================================================
--- head/sys/dev/aac/aac.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/aac/aac.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -55,7 +55,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/rman.h>
 
 #include <machine/bus.h>
-#include <sys/bus_dma.h>
 #include <machine/resource.h>
 
 #include <dev/pci/pcireg.h>

Modified: head/sys/dev/aacraid/aacraid.c
==============================================================================
--- head/sys/dev/aacraid/aacraid.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/aacraid/aacraid.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -56,7 +56,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/rman.h>
 
 #include <machine/bus.h>
-#include <sys/bus_dma.h>
 #include <machine/resource.h>
 
 #include <dev/pci/pcireg.h>

Modified: head/sys/dev/bnxt/bnxt.h
==============================================================================
--- head/sys/dev/bnxt/bnxt.h	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/bnxt/bnxt.h	Sat Jul  1 05:35:29 2017	(r320528)
@@ -32,12 +32,12 @@ __FBSDID("$FreeBSD$");
 #ifndef _BNXT_H
 #define _BNXT_H
 
-#include <sys/types.h>
-#include <sys/bus.h>
-#include <sys/bus_dma.h>
+#include <sys/param.h>
 #include <sys/socket.h>
 #include <sys/sysctl.h>
 #include <sys/taskqueue.h>
+
+#include <machine/bus.h>
 
 #include <net/ethernet.h>
 #include <net/if.h>

Modified: head/sys/dev/cxgb/cxgb_adapter.h
==============================================================================
--- head/sys/dev/cxgb/cxgb_adapter.h	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/cxgb/cxgb_adapter.h	Sat Jul  1 05:35:29 2017	(r320528)
@@ -54,7 +54,6 @@ $FreeBSD$
 #include <machine/bus.h>
 #include <machine/resource.h>
 
-#include <sys/bus_dma.h>
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
 

Modified: head/sys/dev/cxgb/cxgb_main.c
==============================================================================
--- head/sys/dev/cxgb/cxgb_main.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/cxgb/cxgb_main.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/conf.h>
 #include <machine/bus.h>
 #include <machine/resource.h>
-#include <sys/bus_dma.h>
 #include <sys/ktr.h>
 #include <sys/rman.h>
 #include <sys/ioccom.h>

Modified: head/sys/dev/cxgb/cxgb_sge.c
==============================================================================
--- head/sys/dev/cxgb/cxgb_sge.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/cxgb/cxgb_sge.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/conf.h>
 #include <machine/bus.h>
 #include <machine/resource.h>
-#include <sys/bus_dma.h>
 #include <sys/rman.h>
 #include <sys/queue.h>
 #include <sys/sysctl.h>

Modified: head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.c
==============================================================================
--- head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/conf.h>
 #include <machine/bus.h>
 #include <machine/resource.h>
-#include <sys/bus_dma.h>
 #include <sys/rman.h>
 #include <sys/ioccom.h>
 #include <sys/mbuf.h>

Modified: head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c
==============================================================================
--- head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/conf.h>
 #include <machine/bus.h>
 #include <machine/resource.h>
-#include <sys/bus_dma.h>
 #include <sys/rman.h>
 #include <sys/ioccom.h>
 #include <sys/mbuf.h>

Modified: head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cq.c
==============================================================================
--- head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cq.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cq.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/conf.h>
 #include <machine/bus.h>
 #include <machine/resource.h>
-#include <sys/bus_dma.h>
 #include <sys/rman.h>
 #include <sys/ioccom.h>
 #include <sys/mbuf.h>

Modified: head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_dbg.c
==============================================================================
--- head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_dbg.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_dbg.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/conf.h>
 #include <machine/bus.h>
 #include <machine/resource.h>
-#include <sys/bus_dma.h>
 #include <sys/rman.h>
 #include <sys/ioccom.h>
 #include <sys/mbuf.h>

Modified: head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_ev.c
==============================================================================
--- head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_ev.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_ev.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/conf.h>
 #include <machine/bus.h>
 #include <machine/resource.h>
-#include <sys/bus_dma.h>
 #include <sys/rman.h>
 #include <sys/ioccom.h>
 #include <sys/mbuf.h>

Modified: head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_hal.c
==============================================================================
--- head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_hal.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_hal.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/conf.h>
 #include <machine/bus.h>
 #include <machine/resource.h>
-#include <sys/bus_dma.h>
 #include <sys/rman.h>
 #include <sys/ioccom.h>
 #include <sys/mbuf.h>

Modified: head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_mem.c
==============================================================================
--- head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_mem.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_mem.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/conf.h>
 #include <machine/bus.h>
 #include <machine/resource.h>
-#include <sys/bus_dma.h>
 #include <sys/rman.h>
 #include <sys/ioccom.h>
 #include <sys/mbuf.h>

Modified: head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
==============================================================================
--- head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/conf.h>
 #include <machine/bus.h>
 #include <machine/resource.h>
-#include <sys/bus_dma.h>
 #include <sys/rman.h>
 #include <sys/ioccom.h>
 #include <sys/mbuf.h>

Modified: head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_qp.c
==============================================================================
--- head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_qp.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_qp.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/conf.h>
 #include <machine/bus.h>
 #include <machine/resource.h>
-#include <sys/bus_dma.h>
 #include <sys/rman.h>
 #include <sys/ioccom.h>
 #include <sys/mbuf.h>

Modified: head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_resource.c
==============================================================================
--- head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_resource.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_resource.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/conf.h>
 #include <machine/bus.h>
 #include <machine/resource.h>
-#include <sys/bus_dma.h>
 #include <sys/rman.h>
 #include <sys/ioccom.h>
 #include <sys/mbuf.h>

Modified: head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
==============================================================================
--- head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -62,7 +62,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/sglist.h>
 #include <sys/eventhandler.h>
 #include <machine/bus.h>
-#include <sys/bus_dma.h>
 
 #include <cam/cam.h>
 #include <cam/cam_ccb.h>

Modified: head/sys/dev/mfi/mfi.c
==============================================================================
--- head/sys/dev/mfi/mfi.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/mfi/mfi.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -67,7 +67,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/conf.h>
 #include <sys/eventhandler.h>
 #include <sys/rman.h>
-#include <sys/bus_dma.h>
 #include <sys/bio.h>
 #include <sys/ioccom.h>
 #include <sys/uio.h>

Modified: head/sys/dev/mfi/mfi_cam.c
==============================================================================
--- head/sys/dev/mfi/mfi_cam.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/mfi/mfi_cam.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/conf.h>
 #include <sys/eventhandler.h>
 #include <sys/rman.h>
-#include <sys/bus_dma.h>
 #include <sys/bio.h>
 #include <sys/ioccom.h>
 #include <sys/uio.h>

Modified: head/sys/dev/tsec/if_tsec.c
==============================================================================
--- head/sys/dev/tsec/if_tsec.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/tsec/if_tsec.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -37,7 +37,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/bus.h>
-#include <sys/bus_dma.h>
 #include <sys/endian.h>
 #include <sys/mbuf.h>
 #include <sys/kernel.h>

Modified: head/sys/dev/xdma/xdma.c
==============================================================================
--- head/sys/dev/xdma/xdma.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/xdma/xdma.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/sysctl.h>
 #include <sys/systm.h>
 #include <sys/sx.h>
-#include <sys/bus_dma.h>
 
 #include <machine/bus.h>
 

Modified: head/sys/dev/xen/blkfront/blkfront.c
==============================================================================
--- head/sys/dev/xen/blkfront/blkfront.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/dev/xen/blkfront/blkfront.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -49,7 +49,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/resource.h>
 #include <machine/intr_machdep.h>
 #include <machine/vmparam.h>
-#include <sys/bus_dma.h>
 
 #include <xen/xen-os.h>
 #include <xen/hypervisor.h>

Modified: head/sys/i386/include/bus_dma.h
==============================================================================
--- head/sys/i386/include/bus_dma.h	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/i386/include/bus_dma.h	Sat Jul  1 05:35:29 2017	(r320528)
@@ -29,6 +29,6 @@
 #ifndef _I386_BUS_DMA_H_
 #define _I386_BUS_DMA_H_
 
-#include <sys/bus_dma.h>
+#include <x86/bus_dma.h> 
 
 #endif /* _I386_BUS_DMA_H_ */

Modified: head/sys/mips/include/bus_dma.h
==============================================================================
--- head/sys/mips/include/bus_dma.h	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/mips/include/bus_dma.h	Sat Jul  1 05:35:29 2017	(r320528)
@@ -30,5 +30,6 @@
 #define _MIPS_BUS_DMA_H_
 
 #include <sys/bus_dma.h>
+#include <sys/bus_dma_internal.h>
 
 #endif /* _MIPS_BUS_DMA_H_ */

Modified: head/sys/mips/mips/busdma_machdep.c
==============================================================================
--- head/sys/mips/mips/busdma_machdep.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/mips/mips/busdma_machdep.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -930,7 +930,7 @@ _bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t
 	 * Did we fit?
 	 */
 	if (buflen != 0) {
-		_bus_dmamap_unload(dmat, map);
+		bus_dmamap_unload(dmat, map);
 		return (EFBIG); /* XXX better return value here? */
 	}
 	return (0);
@@ -1028,14 +1028,14 @@ cleanup:
 	 * Did we fit?
 	 */
 	if (buflen != 0) {
-		_bus_dmamap_unload(dmat, map);
+		bus_dmamap_unload(dmat, map);
 		error = EFBIG; /* XXX better return value here? */
 	}
 	return (error);
 }
 
 void
-__bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
+_bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
     struct memdesc *mem, bus_dmamap_callback_t *callback, void *callback_arg)
 {
 
@@ -1060,7 +1060,7 @@ _bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t 
  * Release the mapping held by map.
  */
 void
-_bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map)
+bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map)
 {
 	struct bounce_page *bpage;
 
@@ -1233,7 +1233,7 @@ _bus_dmamap_sync_bp(bus_dma_tag_t dmat, bus_dmamap_t m
 }
 
 void
-_bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op)
+bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op)
 {
 	struct sync_list *sl, *end;
 	int aligned;

Modified: head/sys/net/iflib.h
==============================================================================
--- head/sys/net/iflib.h	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/net/iflib.h	Sat Jul  1 05:35:29 2017	(r320528)
@@ -33,7 +33,6 @@
 #include <sys/bus.h>
 #include <sys/cpuset.h>
 #include <machine/bus.h>
-#include <sys/bus_dma.h>
 #include <sys/nv.h>
 #include <sys/gtaskqueue.h>
 

Modified: head/sys/powerpc/include/bus_dma.h
==============================================================================
--- head/sys/powerpc/include/bus_dma.h	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/powerpc/include/bus_dma.h	Sat Jul  1 05:35:29 2017	(r320528)
@@ -29,6 +29,7 @@
 #define _POWERPC_BUS_DMA_H_
 
 #include <sys/bus_dma.h>
+#include <sys/bus_dma_internal.h>
 
 struct device;
 

Modified: head/sys/powerpc/powerpc/busdma_machdep.c
==============================================================================
--- head/sys/powerpc/powerpc/busdma_machdep.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/powerpc/powerpc/busdma_machdep.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -841,7 +841,7 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dmat,
 }
 
 void
-__bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
+_bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
 		    struct memdesc *mem, bus_dmamap_callback_t *callback,
 		    void *callback_arg)
 {
@@ -879,7 +879,7 @@ _bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t 
  * Release the mapping held by map.
  */
 void
-_bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map)
+bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map)
 {
 	struct bounce_page *bpage;
 
@@ -895,7 +895,7 @@ _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t ma
 }
 
 void
-_bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op)
+bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op)
 {
 	struct bounce_page *bpage;
 	vm_offset_t datavaddr, tempvaddr;

Modified: head/sys/riscv/include/bus_dma.h
==============================================================================
--- head/sys/riscv/include/bus_dma.h	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/riscv/include/bus_dma.h	Sat Jul  1 05:35:29 2017	(r320528)
@@ -4,5 +4,6 @@
 #define	_MACHINE_BUS_DMA_H_
 
 #include <sys/bus_dma.h>
+#include <sys/bus_dma_internal.h>
 
 #endif /* !_MACHINE_BUS_DMA_H_ */

Modified: head/sys/riscv/riscv/busdma_machdep.c
==============================================================================
--- head/sys/riscv/riscv/busdma_machdep.c	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/riscv/riscv/busdma_machdep.c	Sat Jul  1 05:35:29 2017	(r320528)
@@ -69,7 +69,7 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dmamap
 }
 
 void
-__bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
+_bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
     struct memdesc *mem, bus_dmamap_callback_t *callback, void *callback_arg)
 {
 
@@ -88,14 +88,14 @@ _bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t 
  * Release the mapping held by map.
  */
 void
-_bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map)
+bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map)
 {
 
 	panic("busdma");
 }
 
 void
-_bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op)
+bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op)
 {
 
 	panic("busdma");

Modified: head/sys/sparc64/include/bus_dma.h
==============================================================================
--- head/sys/sparc64/include/bus_dma.h	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/sparc64/include/bus_dma.h	Sat Jul  1 05:35:29 2017	(r320528)
@@ -68,6 +68,7 @@
 #ifndef _SPARC64_BUS_DMA_H
 #define _SPARC64_BUS_DMA_H
 
+#define WANT_INLINE_DMAMAP
 #include <sys/bus_dma.h>
 
 /* DMA support */
@@ -124,29 +125,95 @@ struct bus_dma_tag {
 	struct bus_dma_methods	*dt_mt;
 };
 
-#define	bus_dmamap_create(t, f, p)					\
-	((t)->dt_mt->dm_dmamap_create((t), (f), (p)))
-#define	bus_dmamap_destroy(t, p)					\
-	((t)->dt_mt->dm_dmamap_destroy((t), (p)))
-#define	_bus_dmamap_load_phys(t, m, b, l, f, s, sp)			\
-	((t)->dt_mt->dm_dmamap_load_phys((t), (m), (b), (l),		\
-	    (f), (s), (sp)))
-#define	_bus_dmamap_load_buffer(t, m, b, l, p, f, s, sp)		\
-	((t)->dt_mt->dm_dmamap_load_buffer((t), (m), (b), (l), (p),	\
-	    (f), (s), (sp)))
-#define	_bus_dmamap_waitok(t, m, mem, c, ca)				\
-	((t)->dt_mt->dm_dmamap_waitok((t), (m), (mem), (c), (ca)))
-#define	_bus_dmamap_complete(t, m, s, n, e)				\
-	((t)->dt_mt->dm_dmamap_complete((t), (m), (s), (n), (e)))
-#define	bus_dmamap_unload(t, p)						\
-	((t)->dt_mt->dm_dmamap_unload((t), (p)))
-#define	bus_dmamap_sync(t, m, op)					\
-	((t)->dt_mt->dm_dmamap_sync((t), (m), (op)))
-#define	bus_dmamem_alloc(t, v, f, m)					\
-	((t)->dt_mt->dm_dmamem_alloc((t), (v), (f), (m)))
-#define	bus_dmamem_free(t, v, m)					\
-	((t)->dt_mt->dm_dmamem_free((t), (v), (m)))
-#define _bus_dmamap_load_ma(t, m, a, tt, o, f, s, p)			\
-	bus_dmamap_load_ma_triv((t), (m), (a), (tt), (o), (f), (s), (p))
+static inline int
+bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
+{
+
+	return (dmat->dt_mt->dm_dmamap_create(dmat, flags, mapp));
+}
+
+static inline int
+bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map)
+{
+
+	return (dmat->dt_mt->dm_dmamap_destroy(dmat, map));
+}
+
+static inline void
+bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op)
+{
+
+	dmat->dt_mt->dm_dmamap_sync(dmat, map, op);
+}
+
+static inline void
+bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map)
+{
+
+	dmat->dt_mt->dm_dmamap_unload(dmat, map);
+}
+
+static inline int
+bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, bus_dmamap_t *mapp)
+{
+
+	return (dmat->dt_mt->dm_dmamem_alloc(dmat, vaddr, flags, mapp));
+}
+
+static inline void
+bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map)
+{
+
+	dmat->dt_mt->dm_dmamem_free(dmat, vaddr, map);
+}
+
+static inline bus_dma_segment_t*
+_bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t map,
+    bus_dma_segment_t *segs, int nsegs, int error)
+{
+
+	return (dmat->dt_mt->dm_dmamap_complete(dmat, map, segs,
+	    nsegs, error));
+}
+
+static inline int
+_bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dmamap_t map,
+    void *buf, bus_size_t buflen, struct pmap *pmap,
+    int flags, bus_dma_segment_t *segs, int *segp)
+{
+
+	return (dmat->dt_mt->dm_dmamap_load_buffer(dmat, map, buf, buflen,
+	    pmap, flags, segs, segp));
+}
+
+static inline int
+_bus_dmamap_load_ma(bus_dma_tag_t dmat, bus_dmamap_t map,
+    struct vm_page **ma, bus_size_t tlen, int ma_offs,
+    int flags, bus_dma_segment_t *segs, int *segp)
+{
+
+	return (bus_dmamap_load_ma_triv(dmat, map, ma, tlen, ma_offs, flags,
+	    segs, segp));
+}
+
+static inline int
+_bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t map,
+    vm_paddr_t paddr, bus_size_t buflen,
+    int flags, bus_dma_segment_t *segs, int *segp)
+{
+
+	return (dmat->dt_mt->dm_dmamap_load_phys(dmat, map, paddr, buflen,
+	    flags, segs, segp));
+}
+
+static inline void
+_bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
+    struct memdesc *mem, bus_dmamap_callback_t *callback,
+    void *callback_arg)
+{
+
+	return (dmat->dt_mt->dm_dmamap_waitok(dmat, map, mem, callback,
+	    callback_arg));
+}
 
 #endif /* !_SPARC64_BUS_DMA_H_ */

Modified: head/sys/sys/bus_dma.h
==============================================================================
--- head/sys/sys/bus_dma.h	Sat Jul  1 05:27:40 2017	(r320527)
+++ head/sys/sys/bus_dma.h	Sat Jul  1 05:35:29 2017	(r320528)
@@ -248,105 +248,49 @@ int bus_dmamap_load_ma_triv(bus_dma_tag_t dmat, bus_dm
     struct vm_page **ma, bus_size_t tlen, int ma_offs, int flags,
     bus_dma_segment_t *segs, int *segp);
 
-/*
- * XXX sparc64 uses the same interface, but a much different implementation.
- *     <machine/bus_dma.h> for the sparc64 arch contains the equivalent
- *     declarations.
- */
-#if !defined(__sparc64__)
+#ifdef WANT_INLINE_DMAMAP
+#define BUS_DMAMAP_OP static inline
+#else
+#define BUS_DMAMAP_OP
+#endif
 
 /*
  * Allocate a handle for mapping from kva/uva/physical
  * address space into bus device space.
  */
-int bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp);
+BUS_DMAMAP_OP int bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp);
 
 /*
  * Destroy a handle for mapping from kva/uva/physical
  * address space into bus device space.
  */
-int bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map);
+BUS_DMAMAP_OP int bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map);
 
 /*
  * Allocate a piece of memory that can be efficiently mapped into
  * bus device space based on the constraints listed in the dma tag.
  * A dmamap to for use with dmamap_load is also allocated.
  */
-int bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
+BUS_DMAMAP_OP int bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
 		     bus_dmamap_t *mapp);
 
 /*
  * Free a piece of memory and its allocated dmamap, that was allocated
  * via bus_dmamem_alloc.
  */
-void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map);
+BUS_DMAMAP_OP void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map);
 
 /*
  * Perform a synchronization operation on the given map. If the map
- * is NULL we have a fully IO-coherent system. On every ARM architecture
- * there must be a memory barrier placed to ensure that all data
- * accesses are visible before going any further.
+ * is NULL we have a fully IO-coherent system.
  */
-void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t);
-#if defined(__arm__)
-	#define __BUS_DMAMAP_SYNC_DEFAULT		mb()
-#elif defined(__aarch64__)
-	#define	__BUS_DMAMAP_SYNC_DEFAULT		dmb(sy)
-#else
-	#define	__BUS_DMAMAP_SYNC_DEFAULT		do {} while (0)
-#endif
-#define bus_dmamap_sync(dmat, dmamap, op) 			\
-	do {							\
-		if ((dmamap) != NULL)				\
-			_bus_dmamap_sync(dmat, dmamap, op);	\
-		else						\
-			__BUS_DMAMAP_SYNC_DEFAULT;		\
-	} while (0)
+BUS_DMAMAP_OP void bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t dmamap, bus_dmasync_op_t op);
 
 /*
  * Release the mapping held by map.
  */
-void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map);
-#define bus_dmamap_unload(dmat, dmamap) 			\
-	do {							\
-		if ((dmamap) != NULL)				\
-			_bus_dmamap_unload(dmat, dmamap);	\
-	} while (0)
+BUS_DMAMAP_OP void bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t dmamap);
 
-/*
- * The following functions define the interface between the MD and MI
- * busdma layers.  These are not intended for consumption by driver
- * software.
- */
-void __bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
-			 struct memdesc *mem,

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



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