Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F101984483
D45047.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
11 KB
Referenced Files
None
Subscribers
None
D45047.diff
View Options
diff --git a/sys/arm/arm/busdma_machdep.c b/sys/arm/arm/busdma_machdep.c
--- a/sys/arm/arm/busdma_machdep.c
+++ b/sys/arm/arm/busdma_machdep.c
@@ -168,11 +168,15 @@
MALLOC_DEFINE(M_BUSDMA, "busdma", "busdma metadata");
#define dmat_alignment(dmat) ((dmat)->alignment)
+#define dmat_bounce_flags(dmat) (0)
+#define dmat_boundary(dmat) ((dmat)->boundary)
#define dmat_flags(dmat) ((dmat)->flags)
#define dmat_highaddr(dmat) ((dmat)->highaddr)
#define dmat_lowaddr(dmat) ((dmat)->lowaddr)
#define dmat_lockfunc(dmat) ((dmat)->lockfunc)
#define dmat_lockfuncarg(dmat) ((dmat)->lockfuncarg)
+#define dmat_maxsegsz(dmat) ((dmat)->maxsegsz)
+#define dmat_nsegments(dmat) ((dmat)->nsegments)
#include "../../kern/subr_busdma_bounce.c"
@@ -842,47 +846,6 @@
}
}
-/*
- * Add a single contiguous physical range to the segment list.
- */
-static int
-_bus_dmamap_addseg(bus_dma_tag_t dmat, bus_dmamap_t map, bus_addr_t curaddr,
- bus_size_t sgsize, bus_dma_segment_t *segs, int *segp)
-{
- int seg;
-
- /*
- * Make sure we don't cross any boundaries.
- */
- if (!vm_addr_bound_ok(curaddr, sgsize, dmat->boundary))
- sgsize = roundup2(curaddr, dmat->boundary) - curaddr;
-
- /*
- * Insert chunk into a segment, coalescing with
- * previous segment if possible.
- */
- seg = *segp;
- if (seg == -1) {
- seg = 0;
- segs[seg].ds_addr = curaddr;
- segs[seg].ds_len = sgsize;
- } else {
- if (curaddr == segs[seg].ds_addr + segs[seg].ds_len &&
- (segs[seg].ds_len + sgsize) <= dmat->maxsegsz &&
- vm_addr_bound_ok(segs[seg].ds_addr,
- segs[seg].ds_len + sgsize, dmat->boundary))
- segs[seg].ds_len += sgsize;
- else {
- if (++seg >= dmat->nsegments)
- return (0);
- segs[seg].ds_addr = curaddr;
- segs[seg].ds_len = sgsize;
- }
- }
- *segp = seg;
- return (sgsize);
-}
-
/*
* Utility function to load a physical buffer. segp contains
* the starting segment on entrace, and the ending segment on exit.
diff --git a/sys/arm64/arm64/busdma_bounce.c b/sys/arm64/arm64/busdma_bounce.c
--- a/sys/arm64/arm64/busdma_bounce.c
+++ b/sys/arm64/arm64/busdma_bounce.c
@@ -121,12 +121,16 @@
static MALLOC_DEFINE(M_BUSDMA, "busdma", "busdma metadata");
#define dmat_alignment(dmat) ((dmat)->common.alignment)
+#define dmat_bounce_flags(dmat) ((dmat)->bounce_flags)
+#define dmat_boundary(dmat) ((dmat)->common.boundary)
#define dmat_domain(dmat) ((dmat)->common.domain)
#define dmat_flags(dmat) ((dmat)->common.flags)
#define dmat_highaddr(dmat) ((dmat)->common.highaddr)
#define dmat_lowaddr(dmat) ((dmat)->common.lowaddr)
#define dmat_lockfunc(dmat) ((dmat)->common.lockfunc)
#define dmat_lockfuncarg(dmat) ((dmat)->common.lockfuncarg)
+#define dmat_maxsegsz(dmat) ((dmat)->common.maxsegsz)
+#define dmat_nsegments(dmat) ((dmat)->common.nsegments)
#include "../../kern/subr_busdma_bounce.c"
@@ -711,47 +715,6 @@
}
}
-/*
- * Add a single contiguous physical range to the segment list.
- */
-static bus_size_t
-_bus_dmamap_addseg(bus_dma_tag_t dmat, bus_dmamap_t map, bus_addr_t curaddr,
- bus_size_t sgsize, bus_dma_segment_t *segs, int *segp)
-{
- int seg;
-
- /*
- * Make sure we don't cross any boundaries.
- */
- if (!vm_addr_bound_ok(curaddr, sgsize, dmat->common.boundary))
- sgsize = roundup2(curaddr, dmat->common.boundary) - curaddr;
-
- /*
- * Insert chunk into a segment, coalescing with
- * previous segment if possible.
- */
- seg = *segp;
- if (seg == -1) {
- seg = 0;
- segs[seg].ds_addr = curaddr;
- segs[seg].ds_len = sgsize;
- } else {
- if (curaddr == segs[seg].ds_addr + segs[seg].ds_len &&
- (segs[seg].ds_len + sgsize) <= dmat->common.maxsegsz &&
- vm_addr_bound_ok(segs[seg].ds_addr,
- segs[seg].ds_len + sgsize, dmat->common.boundary))
- segs[seg].ds_len += sgsize;
- else {
- if (++seg >= dmat->common.nsegments)
- return (0);
- segs[seg].ds_addr = curaddr;
- segs[seg].ds_len = sgsize;
- }
- }
- *segp = seg;
- return (sgsize);
-}
-
/*
* Utility function to load a physical buffer. segp contains
* the starting segment on entrace, and the ending segment on exit.
diff --git a/sys/kern/subr_busdma_bounce.c b/sys/kern/subr_busdma_bounce.c
--- a/sys/kern/subr_busdma_bounce.c
+++ b/sys/kern/subr_busdma_bounce.c
@@ -451,6 +451,54 @@
wakeup(&bounce_map_callbacklist);
}
+/*
+ * Add a single contiguous physical range to the segment list.
+ */
+static bus_size_t
+_bus_dmamap_addseg(bus_dma_tag_t dmat, bus_dmamap_t map, bus_addr_t curaddr,
+ bus_size_t sgsize, bus_dma_segment_t *segs, int *segp)
+{
+ int seg;
+
+ KASSERT(curaddr <= BUS_SPACE_MAXADDR,
+ ("ds_addr %#jx > BUS_SPACE_MAXADDR %#jx; dmat %p fl %#x low %#jx "
+ "hi %#jx",
+ (uintmax_t)curaddr, (uintmax_t)BUS_SPACE_MAXADDR,
+ dmat, dmat_bounce_flags(dmat), (uintmax_t)dmat_lowaddr(dmat),
+ (uintmax_t)dmat_highaddr(dmat)));
+
+ /*
+ * Make sure we don't cross any boundaries.
+ */
+ if (!vm_addr_bound_ok(curaddr, sgsize, dmat_boundary(dmat)))
+ sgsize = roundup2(curaddr, dmat_boundary(dmat)) - curaddr;
+
+ /*
+ * Insert chunk into a segment, coalescing with
+ * previous segment if possible.
+ */
+ seg = *segp;
+ if (seg == -1) {
+ seg = 0;
+ segs[seg].ds_addr = curaddr;
+ segs[seg].ds_len = sgsize;
+ } else {
+ if (curaddr == segs[seg].ds_addr + segs[seg].ds_len &&
+ (segs[seg].ds_len + sgsize) <= dmat_maxsegsz(dmat) &&
+ vm_addr_bound_ok(segs[seg].ds_addr,
+ segs[seg].ds_len + sgsize, dmat_boundary(dmat)))
+ segs[seg].ds_len += sgsize;
+ else {
+ if (++seg >= dmat_nsegments(dmat))
+ return (0);
+ segs[seg].ds_addr = curaddr;
+ segs[seg].ds_len = sgsize;
+ }
+ }
+ *segp = seg;
+ return (sgsize);
+}
+
static void
busdma_thread(void *dummy __unused)
{
diff --git a/sys/powerpc/powerpc/busdma_machdep.c b/sys/powerpc/powerpc/busdma_machdep.c
--- a/sys/powerpc/powerpc/busdma_machdep.c
+++ b/sys/powerpc/powerpc/busdma_machdep.c
@@ -100,11 +100,15 @@
static MALLOC_DEFINE(M_BUSDMA, "busdma", "busdma metadata");
#define dmat_alignment(dmat) ((dmat)->alignment)
+#define dmat_bounce_flags(dmat) (0)
+#define dmat_boundary(dmat) ((dmat)->boundary)
#define dmat_flags(dmat) ((dmat)->flags)
#define dmat_highaddr(dmat) ((dmat)->highaddr)
#define dmat_lowaddr(dmat) ((dmat)->lowaddr)
#define dmat_lockfunc(dmat) ((dmat)->lockfunc)
#define dmat_lockfuncarg(dmat) ((dmat)->lockfuncarg)
+#define dmat_maxsegsz(dmat) ((dmat)->maxsegsz)
+#define dmat_nsegments(dmat) ((dmat)->nsegments)
#include "../../kern/subr_busdma_bounce.c"
@@ -535,47 +539,6 @@
}
}
-/*
- * Add a single contiguous physical range to the segment list.
- */
-static int
-_bus_dmamap_addseg(bus_dma_tag_t dmat, bus_dmamap_t map, bus_addr_t curaddr,
- bus_size_t sgsize, bus_dma_segment_t *segs, int *segp)
-{
- int seg;
-
- /*
- * Make sure we don't cross any boundaries.
- */
- if (!vm_addr_bound_ok(curaddr, sgsize, dmat->boundary))
- sgsize = roundup2(curaddr, dmat->boundary) - curaddr;
-
- /*
- * Insert chunk into a segment, coalescing with
- * previous segment if possible.
- */
- seg = *segp;
- if (seg == -1) {
- seg = 0;
- segs[seg].ds_addr = curaddr;
- segs[seg].ds_len = sgsize;
- } else {
- if (curaddr == segs[seg].ds_addr + segs[seg].ds_len &&
- (segs[seg].ds_len + sgsize) <= dmat->maxsegsz &&
- vm_addr_bound_ok(segs[seg].ds_addr,
- segs[seg].ds_len + sgsize, dmat->boundary))
- segs[seg].ds_len += sgsize;
- else {
- if (++seg >= dmat->nsegments)
- return (0);
- segs[seg].ds_addr = curaddr;
- segs[seg].ds_len = sgsize;
- }
- }
- *segp = seg;
- return (sgsize);
-}
-
/*
* Utility function to load a physical buffer. segp contains
* the starting segment on entrace, and the ending segment on exit.
diff --git a/sys/riscv/riscv/busdma_bounce.c b/sys/riscv/riscv/busdma_bounce.c
--- a/sys/riscv/riscv/busdma_bounce.c
+++ b/sys/riscv/riscv/busdma_bounce.c
@@ -111,11 +111,15 @@
static MALLOC_DEFINE(M_BUSDMA, "busdma", "busdma metadata");
#define dmat_alignment(dmat) ((dmat)->common.alignment)
+#define dmat_bounce_flags(dmat) ((dmat)->bounce_flags)
+#define dmat_boundary(dmat) ((dmat)->common.boundary)
#define dmat_flags(dmat) ((dmat)->common.flags)
#define dmat_highaddr(dmat) ((dmat)->common.highaddr)
#define dmat_lowaddr(dmat) ((dmat)->common.lowaddr)
#define dmat_lockfunc(dmat) ((dmat)->common.lockfunc)
#define dmat_lockfuncarg(dmat) ((dmat)->common.lockfuncarg)
+#define dmat_maxsegsz(dmat) ((dmat)->common.maxsegsz)
+#define dmat_nsegments(dmat) ((dmat)->common.nsegments)
#include "../../kern/subr_busdma_bounce.c"
@@ -547,47 +551,6 @@
}
}
-/*
- * Add a single contiguous physical range to the segment list.
- */
-static bus_size_t
-_bus_dmamap_addseg(bus_dma_tag_t dmat, bus_dmamap_t map, bus_addr_t curaddr,
- bus_size_t sgsize, bus_dma_segment_t *segs, int *segp)
-{
- int seg;
-
- /*
- * Make sure we don't cross any boundaries.
- */
- if (!vm_addr_bound_ok(curaddr, sgsize, dmat->common.boundary))
- sgsize = roundup2(curaddr, dmat->common.boundary) - curaddr;
-
- /*
- * Insert chunk into a segment, coalescing with
- * previous segment if possible.
- */
- seg = *segp;
- if (seg == -1) {
- seg = 0;
- segs[seg].ds_addr = curaddr;
- segs[seg].ds_len = sgsize;
- } else {
- if (curaddr == segs[seg].ds_addr + segs[seg].ds_len &&
- (segs[seg].ds_len + sgsize) <= dmat->common.maxsegsz &&
- vm_addr_bound_ok(segs[seg].ds_addr,
- segs[seg].ds_len + sgsize, dmat->common.boundary))
- segs[seg].ds_len += sgsize;
- else {
- if (++seg >= dmat->common.nsegments)
- return (0);
- segs[seg].ds_addr = curaddr;
- segs[seg].ds_len = sgsize;
- }
- }
- *segp = seg;
- return (sgsize);
-}
-
/*
* Utility function to load a physical buffer. segp contains
* the starting segment on entrace, and the ending segment on exit.
diff --git a/sys/x86/x86/busdma_bounce.c b/sys/x86/x86/busdma_bounce.c
--- a/sys/x86/x86/busdma_bounce.c
+++ b/sys/x86/x86/busdma_bounce.c
@@ -108,12 +108,16 @@
static MALLOC_DEFINE(M_BUSDMA, "busdma", "busdma metadata");
#define dmat_alignment(dmat) ((dmat)->common.alignment)
+#define dmat_bounce_flags(dmat) ((dmat)->bounce_flags)
+#define dmat_boundary(dmat) ((dmat)->common.boundary)
#define dmat_domain(dmat) ((dmat)->common.domain)
#define dmat_flags(dmat) ((dmat)->common.flags)
#define dmat_highaddr(dmat) ((dmat)->common.highaddr)
#define dmat_lowaddr(dmat) ((dmat)->common.lowaddr)
#define dmat_lockfunc(dmat) ((dmat)->common.lockfunc)
#define dmat_lockfuncarg(dmat) ((dmat)->common.lockfuncarg)
+#define dmat_maxsegsz(dmat) ((dmat)->common.maxsegsz)
+#define dmat_nsegments(dmat) ((dmat)->common.nsegments)
#include "../../kern/subr_busdma_bounce.c"
@@ -622,54 +626,6 @@
}
}
-/*
- * Add a single contiguous physical range to the segment list.
- */
-static bus_size_t
-_bus_dmamap_addseg(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t curaddr,
- bus_size_t sgsize, bus_dma_segment_t *segs, int *segp)
-{
- int seg;
-
- KASSERT(curaddr <= BUS_SPACE_MAXADDR,
- ("ds_addr %#jx > BUS_SPACE_MAXADDR %#jx; dmat %p fl %#x low %#jx "
- "hi %#jx",
- (uintmax_t)curaddr, (uintmax_t)BUS_SPACE_MAXADDR,
- dmat, dmat->bounce_flags, (uintmax_t)dmat->common.lowaddr,
- (uintmax_t)dmat->common.highaddr));
-
- /*
- * Make sure we don't cross any boundaries.
- */
- if (!vm_addr_bound_ok(curaddr, sgsize, dmat->common.boundary))
- sgsize = roundup2(curaddr, dmat->common.boundary) - curaddr;
-
- /*
- * Insert chunk into a segment, coalescing with
- * previous segment if possible.
- */
- seg = *segp;
- if (seg == -1) {
- seg = 0;
- segs[seg].ds_addr = curaddr;
- segs[seg].ds_len = sgsize;
- } else {
- if (curaddr == segs[seg].ds_addr + segs[seg].ds_len &&
- (segs[seg].ds_len + sgsize) <= dmat->common.maxsegsz &&
- vm_addr_bound_ok(segs[seg].ds_addr,
- segs[seg].ds_len + sgsize, dmat->common.boundary))
- segs[seg].ds_len += sgsize;
- else {
- if (++seg >= dmat->common.nsegments)
- return (0);
- segs[seg].ds_addr = curaddr;
- segs[seg].ds_len = sgsize;
- }
- }
- *segp = seg;
- return (sgsize);
-}
-
/*
* Utility function to load a physical buffer. segp contains
* the starting segment on entrace, and the ending segment on exit.
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 7, 4:30 AM (22 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14504677
Default Alt Text
D45047.diff (11 KB)
Attached To
Mode
D45047: busdma: deduplicate _bus_dmamap_addseg() function
Attached
Detach File
Event Timeline
Log In to Comment