rust: dma_fence: gate abstractions on CONFIG_DMA_SHARED_BUFFER
Subsystems (2)
PATCH 1/1 rust: dma_fence: gate abstractions on CONFIG_DMA_SHARED_BUFFER
The dma_fence abstractions added by commit 3282d5916019 ("rust: Add dma_fence abstractions") are compiled unconditionally, but the C dma_fence_* symbols they reference live in drivers/dma-buf/dma-fence.c, which is only built when CONFIG_DMA_SHARED_BUFFER=y. Kernels with CONFIG_RUST=y and CONFIG_RUST_KERNEL_DOCTESTS=y but CONFIG_DMA_SHARED_BUFFER=n fail to link:
ld.lld: error: undefined symbol: dma_fence_release
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
referenced by
usercopy_64.c
vmlinux.o:(rust_helper_dma_fence_put)
... dma_fence_signal{,_locked}, dma_fence_context_alloc,
dma_fence_init, dma_fence_{add,remove}_callback ...
Wrap the dma_fence.c helper include in the samepub mod dma_buf; in rust/kernel/lib.rs with a matching #[cfg].
--- rust/helpers/helpers.c | 2 +- rust/kernel/lib.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
rust/helpers/helpers.c +1 -1
@@ -57,8 +57,8 @@#include "cred.c" #include "device.c" #include "dma.c" -#include "dma_fence.c" #ifdef CONFIG_DMA_SHARED_BUFFER +#include "dma_fence.c" #include "dma-resv.c" #endif #include "drm.c"
rust/kernel/lib.rs +1 -0
@@ -67,6 +67,7 @@pub mod device_id;pub mod devres;pub mod dma; +#[cfg( CONFIG_DMA_SHARED_BUFFER )] pub mod dma_buf;pub mod driver;#[cfg( CONFIG_DRM = "y" )]
Signature · 1 line
2.50.1 (Apple Git-155)
Quoted 8 lines · Edwin Peer
The
dma_fenceabstractions added by commit3282d5916019("rust: Adddma_fenceabstractions") are compiled unconditionally, but the Cdma_fence_*symbols they reference live indrivers/dma-buf/dma-fence.c, which is only built whenCONFIG_DMA_SHARED_BUFFER=y. Kernels withCONFIG_RUST=yandCONFIG_RUST_KERNEL_DOCTESTS=ybutCONFIG_DMA_SHARED_BUFFER=nfail to link:
Quoted 8 lines
ld.lld: error: undefined symbol:
dma_fence_release>>> referenced byusercopy_64.c
>>> vmlinux.o:(rust_helper_dma_fence_put) ... dma_fence_signal{,_locked},dma_fence_context_alloc,dma_fence_init, dma_fence_{add,remove}_callback ...Wrap the
dma_fence.chelper include in the samepub mod dma_buf;inrust/kernel/lib.rswith a matching #[cfg].
Oh dear, yes. Sorry about that, thx for fixing!
Quoted 4 lines
Fixes 3282d5916019 ("rust: Add dma_fence abstractions")Signed-off-by Edwin Peer <[email protected]>Reviewed-by John Hubbard <[email protected]>
Quoted 31 lines
---
rust/helpers/helpers.c | 2 +-
rust/kernel/lib.rs | 1 +2 files changed, 2 insertions(+), 1 deletion(-)rust/helpers/helpers.c +1
-1@@ -57,8 +57,8 @@ #include "cred.c" #include "device.c" #include "dma.c" -#include "dma_fence.c" #ifdef CONFIG_DMA_SHARED_BUFFER +#include "dma_fence.c" #include "dma-resv.c" #endif #include "drm.c"rust/kernel/lib.rs +1
-0@@ -67,6 +67,7 @@ pub mod device_id; pub mod devres; pub mod dma; +#[cfg( CONFIG_DMA_SHARED_BUFFER )] pub mod dma_buf; pub mod driver; #[cfg(CONFIG_DRM = "y")]
Quoted 1 line · Edwin Peer
[PATCH drm-rust-next] rust:
dma_fence: gate abstractions onCONFIG_DMA_SHARED_BUFFER
Applied, thanks!
Branch: drm-rust-next
Tree: https://gitlab.freedesktop.org/drm/rust/kernel.git
[1/1] rust: dma_fence: gate abstractions on CONFIG_DMA_SHARED_BUFFER
commit: 73e5616f3d19
The patch will appear in the next linux-next integration (typically within 24 hours on weekdays).
The patch is queued up for the upcoming merge window for the next major kernel release.