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

From: Miguel Ojeda

Date: Sat Jul 11 2026 - 08:55:56 EST


On Wed, Jul 8, 2026 at 1:53 PM Andreas Hindborg <a.hindborg@xxxxxxxxxx> wrote:
>
> 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>

Please see:

https://lore.kernel.org/rust-for-linux/20260708082454.1254320-3-mkchauras@xxxxxxxxx/

Cheers,
Miguel