rust: helpers: guard dma_resv helpers with CONFIG_DMA_SHARED_BUFFER
Subsystems (4)
Andreas Hindborg
reviewerPATCH 1/1 rust: helpers: guard dma_resv helpers with CONFIG_DMA_SHARED_BUFFER
Commit 9b836641d3bf ("rust: helpers: Add bindings/wrappers for dma_resv_lock") added rust_helper_dma_resv_lock() and rust_helper_dma_resv_unlock() unconditionally. However, the dma-resv functionality is only available when CONFIG_DMA_SHARED_BUFFER is enabled, resulting in the following link error when it is not:
LD .tmp_vmlinux1
ld.lld: error: undefined symbol: dma_resv_reset_max_fences >>> referenced by dma-resv.h:463
>>> rust/helpers/helpers.o:(rust_helper_dma_resv_unlock) in archive vmlinux.a
The dma_resv_unlock() inline in <linux/dma-resv.h> calls dma_resv_reset_max_fences(), which is only compiled into drivers/dma-buf/dma-resv.c when CONFIG_DMA_SHARED_BUFFER is set. With the option disabled the symbol is never defined, so the helper fails to link.
Fix this by guarding the helper definitions with #ifdef CONFIG_DMA_SHARED_BUFFER.
The only user of this helper is the DRM shmem abstractions, which already depend on CONFIG_DMA_SHARED_BUFFER.
--- rust/helpers/dma-resv.c | 4 ++++ 1 file changed, 4 insertions(+)
rust/helpers/dma-resv.c +4 -0
@@ -1,5 +1,7 @@// SPDX-License-Identifier: GPL-2.0 +#ifdef CONFIG_DMA_SHARED_BUFFER +#include <linux/dma-resv.h> __rust_helper
@@ -12,3 +14,5 @@ __rust_helper void rust_helper_dma_resv_unlock(struct dma_resv *obj) {dma_resv_unlock (obj); } + +#endif
---
base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
change-id: 20260708-dma-shared-buffer-config-bb135fdb61f4
Best regards,
Signature · 1 line
Andreas Hindborg <[email protected]>
Quoted 21 lines · Andreas Hindborg
Commit
9b836641d3bf("rust: helpers: Add bindings/wrappers fordma_resv_lock") addedrust_helper_dma_resv_lock()andrust_helper_dma_resv_unlock()unconditionally. However, the dma-resv functionality is only available whenCONFIG_DMA_SHARED_BUFFERis enabled, resulting in the following link error when it is not:LD .tmp_vmlinux1
ld.lld: error: undefined symbol:dma_resv_reset_max_fences>>> referenced by dma-resv.h:463
>>> rust/helpers/helpers.o:(rust_helper_dma_resv_unlock) in archive vmlinux.aThe
dma_resv_unlock()inline in <linux/dma-resv.h> callsdma_resv_reset_max_fences(), which is only compiled intodrivers/dma-buf/dma-resv.cwhenCONFIG_DMA_SHARED_BUFFERis set. With the option disabled the symbol is never defined, so the helper fails to link.Fix this by guarding the helper definitions with
#ifdef CONFIG_DMA_SHARED_BUFFER.
Quoted 6 lines
The only user of this helper is the DRM shmem abstractions, which already depend on
CONFIG_DMA_SHARED_BUFFER.Fixes 9b836641d3bf ("rust: helpers: Add bindings/wrappers for dma_resv_lock")Signed-off-by Andreas Hindborg <[email protected]>
Please see:
https://lore.kernel.org/rust-for-linux/[email protected]/
Cheers,
Miguel