]> git.ipfire.org Git - thirdparty/linux.git/commit
rust: dma: add CoherentHandle for DMA allocations without kernel mapping
authorDanilo Krummrich <dakr@kernel.org>
Sat, 21 Mar 2026 17:27:47 +0000 (18:27 +0100)
committerAlexandre Courbot <acourbot@nvidia.com>
Sat, 28 Mar 2026 13:13:23 +0000 (22:13 +0900)
commit6dd782af1eb6be16a80349ea7822f0f8a23bb3e8
tree4e1cdec79108505a98e14180aa6cdcb9eded69cc
parent18fb5f1f0289b8217c0c43d54d12bccc201dd640
rust: dma: add CoherentHandle for DMA allocations without kernel mapping

Add CoherentHandle, an opaque DMA allocation type for buffers that are
only ever accessed by hardware. Unlike Coherent<T>, it does not provide
CPU access to the allocated memory.

CoherentHandle implicitly sets DMA_ATTR_NO_KERNEL_MAPPING and stores the
value returned by dma_alloc_attrs() as an opaque handle
(NonNull<c_void>) rather than a typed pointer, since with this flag the
C API returns an opaque cookie (e.g. struct page *), not a CPU pointer
to the allocated memory.

Only the DMA bus address is exposed to drivers; the opaque handle is
used solely to free the allocation on drop.

This commit is for reference only; there is currently no in-tree user.

Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://patch.msgid.link/20260321172749.592387-2-dakr@kernel.org
[acourbot: fix conflict in dma.rs.]
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
rust/kernel/dma.rs