Page MenuHomeFreeBSD

busdma: Prevent the use of filters with bus_dma_tag_create()
ClosedPublic

Authored by mhorne on Nov 30 2023, 5:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 26, 5:34 PM
Unknown Object (File)
Fri, Apr 26, 5:19 PM
Unknown Object (File)
Sun, Apr 21, 1:34 AM
Unknown Object (File)
Fri, Apr 19, 4:35 PM
Unknown Object (File)
Mon, Apr 8, 11:35 AM
Unknown Object (File)
Apr 1 2024, 10:49 PM
Unknown Object (File)
Mar 30 2024, 3:21 AM
Unknown Object (File)
Mar 28 2024, 9:12 AM

Details

Summary

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 IMO
this is the appropriate step for the lifetime of 15, without actually
breaking the driver API.

I have no real stake in what happens here, nor do I know the whole
history behind the filter functionality. I am trying to clear out some
of my local clean-up branches, and this change enables the removal of a
fair amount of unused complexity across the various busdma
implementations.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

d58ff30aca2abfe6ae31e1bc48424be8b48a9ef6 - "filters may not work correctly"
I'm not really familiar with the issue, but this seems reasonable to me.

If you wanted to be thorough you could start with printing a warning in this case and MFC that to stable/14, making it EINVAL in main?

d58ff30aca2abfe6ae31e1bc48424be8b48a9ef6 - "filters may not work correctly"
I'm not really familiar with the issue, but this seems reasonable to me.

Thanks, I meant to include that hash in the commit message. FWIW, by code inspection filters do appear to work correctly today, but as I note they are unused in the tree.

If you wanted to be thorough you could start with printing a warning in this case and MFC that to stable/14, making it EINVAL in main?

Good suggestion, I'll keep this as-is for the moment but can handle this in due time.

Maybe we need a new function to replace bus_dma_tag_create ? Maybe make it into a varargs macro that calls _ bus_dma_tag_create when the filtargs aren't present, or _bus_dma_tag_create_legacy when they are... Though we may also be able to use macro magic to ensure they are are identical to NULL at compile time (the former I know we can do, the latter I'm not so sure about).

Warnings in 14 and gone in 15 is great. I doubt anybody will see a warning. IIRC, when Scott made this announcement, they'd already been dead for a number of years since we'd removed the only driver that needed them many, many years ago.

We can certainly do macro magic to make it pass NULL, NULL if a macro with fewer args is used and that macro can even be MFC'd to enable cross-branch API compatibility and then kill it in main. That's what I did when axeing the devclass arg to DRIVER_MODULE.

This revision is now accepted and ready to land.Nov 30 2023, 11:49 PM
In D42852#977579, @jhb wrote:

We can certainly do macro magic to make it pass NULL, NULL if a macro with fewer args is used and that macro can even be MFC'd to enable cross-branch API compatibility and then kill it in main. That's what I did when axeing the devclass arg to DRIVER_MODULE.

Sounds good. For me this is a stretch goal that I can handle eventually, but not immediately.