[PATCH] rust: helpers: guard dma_resv helpers with CONFIG_DMA_SHARED_BUFFER

From: Andreas Hindborg

Date: Wed Jul 08 2026 - 07:55:57 EST


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`.

Cc: stable@xxxxxxxxxxxxxxx
Fixes: 9b836641d3bf ("rust: helpers: Add bindings/wrappers for dma_resv_lock")
Signed-off-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
---
rust/helpers/dma-resv.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/rust/helpers/dma-resv.c b/rust/helpers/dma-resv.c
index 71914d8241e2..1698092b9317 100644
--- a/rust/helpers/dma-resv.c
+++ b/rust/helpers/dma-resv.c
@@ -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,
--
Andreas Hindborg <a.hindborg@xxxxxxxxxx>