Skip to content

Commit 7cb028d

Browse files
committed
busdma: Prevent the use of filters with bus_dma_tag_create()
A deprecation notice was added to the bus_dma(9) man page by scottl@ in September 2020 discouraging the use of filter functions. I've performed an attentive check of all callers in the tree and everything that exists today passes NULL for both filtfunc and filtarg. Thus, we should start returning EINVAL if these arguments are non-NULL to prevent new usages from popping up. Update the man page to be more clear about this. The deprecation notice is present since at least 13.0-RELEASE, so this is the appropriate step for the lifetime of 15, without actually breaking the driver API. Stable branches will emit a warning instead. This change enables the removal of a fair amount of unused complexity across the various busdma implementations. Reviewed by: jhb MFC after: never Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D42852
1 parent 47d669f commit 7cb028d

File tree

6 files changed

+32
-20
lines changed

6 files changed

+32
-20
lines changed

share/man/man9/bus_dma.9

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ inclusive.
373373
The filter function should return zero if any mapping in this range
374374
can be accommodated by the device and non-zero otherwise.
375375
.Pp
376-
.Em Note: The use of filters is deprecated. Proper operation is not guaranteed.
376+
.Em Note: The use of filters is no longer supported and will result in an error.
377377
.It Vt bus_dma_segment_t
378378
A machine-dependent type that describes individual
379379
DMA segments.
@@ -611,26 +611,10 @@ This area of
611611
is used to bounce requests that would otherwise conflict with
612612
the exclusion window.
613613
.It Fa filtfunc
614-
Optional filter function (may be
615-
.Dv NULL )
616-
to be called for any attempt to
617-
map memory into the window described by
618-
.Fa lowaddr
619-
and
620-
.Fa highaddr .
621-
A filter function is only required when the single window described
622-
by
623-
.Fa lowaddr
624-
and
625-
.Fa highaddr
626-
cannot adequately describe the constraints of the device.
627-
The filter function will be called for every machine page
628-
that overlaps the exclusion window.
629-
.Pp
630-
.Em Note: The use of filters is deprecated. Proper operation is not guaranteed.
614+
Formerly the optional filter function; must be
615+
.Dv NULL .
631616
.It Fa filtfuncarg
632-
Argument passed to all calls to the filter function for this tag.
633-
May be
617+
Must be
634618
.Dv NULL .
635619
.It Fa maxsize
636620
Maximum size, in bytes, of the sum of all segment lengths in a given
@@ -689,6 +673,14 @@ Returns
689673
.Er ENOMEM
690674
if sufficient memory is not available for tag creation
691675
or allocating mapping resources.
676+
Returns
677+
.Er EINVAL
678+
if either
679+
.Fa filtfunc
680+
or
681+
.Fa filtarg
682+
arguments are not
683+
.Dv NULL .
692684
.It Fn bus_dma_tag_destroy "dmat"
693685
Deallocate the DMA tag
694686
.Fa dmat

sys/arm/arm/busdma_machdep.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
398398
/* Return a NULL tag on failure */
399399
*dmat = NULL;
400400

401+
/* Filters are no longer supported. */
402+
if (filter != NULL || filterarg != NULL)
403+
return (EINVAL);
404+
401405
newtag = (bus_dma_tag_t)malloc(sizeof(*newtag), M_BUSDMA,
402406
M_ZERO | M_NOWAIT);
403407
if (newtag == NULL) {

sys/arm64/arm64/busdma_machdep.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
164164
struct bus_dma_tag_common *tc;
165165
int error;
166166

167+
/* Filters are no longer supported. */
168+
if (filter != NULL || filterarg != NULL)
169+
return (EINVAL);
170+
167171
if (parent == NULL) {
168172
error = bus_dma_bounce_impl.tag_create(parent, alignment,
169173
boundary, lowaddr, highaddr, filter, filterarg, maxsize,

sys/powerpc/powerpc/busdma_machdep.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
168168
return (EINVAL);
169169
}
170170

171+
/* Filters are no longer supported. */
172+
if (filter != NULL || filterarg != NULL)
173+
return (EINVAL);
174+
171175
/* Return a NULL tag on failure */
172176
*dmat = NULL;
173177

sys/riscv/riscv/busdma_machdep.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
161161
struct bus_dma_tag_common *tc;
162162
int error;
163163

164+
/* Filters are no longer supported. */
165+
if (filter != NULL || filterarg != NULL)
166+
return (EINVAL);
167+
164168
if (parent == NULL) {
165169
error = bus_dma_bounce_impl.tag_create(parent, alignment,
166170
boundary, lowaddr, highaddr, filter, filterarg, maxsize,

sys/x86/x86/busdma_machdep.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
184184
struct bus_dma_tag_common *tc;
185185
int error;
186186

187+
/* Filters are no longer supported. */
188+
if (filter != NULL || filterarg != NULL)
189+
return (EINVAL);
190+
187191
if (parent == NULL) {
188192
error = bus_dma_bounce_impl.tag_create(parent, alignment,
189193
boundary, lowaddr, highaddr, filter, filterarg, maxsize,

0 commit comments

Comments
 (0)