From: Asahi Lina <[email protected]> This is just for basic usage in the DRM shmem abstractions for implied locking, not intended as a full DMA Reservation abstraction yet.
Cc: Sumit Semwal <[email protected]> Cc: Christian König <[email protected]> Signed-off-by: Asahi Lina <[email protected]> Signed-off-by: Daniel Almeida <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Signed-off-by: Lyude Paul <[email protected]> Reviewed-by: Janne Grunau <[email protected]> Reviewed-by: Daniel Almeida <[email protected]> Signed-off-by: Alice Ryhl <[email protected]> --- Taken from: https://lore.kernel.org/all/[email protected]/ with __rust_helper and MAINTAINERS file added. --- MAINTAINERS | 1 + rust/bindings/bindings_helper.h | 1 + rust/helpers/dma-resv.c | 14 ++++++++++++++ rust/helpers/helpers.c | 1 + 4 files changed, 17 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index b40923a18066..5d013a36f46f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7534,6 +7534,7 @@ F: include/linux/*fence.h F: include/linux/dma-buf.h F: include/linux/dma-buf/ F: include/linux/dma-resv.h +F: rust/helpers/dma-resv.c K: \bdma_(?:buf|fence|resv)\b DMA GENERIC OFFLOAD ENGINE SUBSYSTEM diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helper.h index ef0f010c268b..47279e993934 100644 --- a/rust/bindings/bindings_helper.h +++ b/rust/bindings/bindings_helper.h @@ -52,6 +52,7 @@ #include <linux/device/faux.h> #include <linux/dma-direction.h> #include <linux/dma-mapping.h> +#include <linux/dma-resv.h> #include <linux/errname.h> #include <linux/ethtool.h> #include <linux/fdtable.h> diff --git a/rust/helpers/dma-resv.c b/rust/helpers/dma-resv.c new file mode 100644 index 000000000000..71914d8241e2 --- /dev/null +++ b/rust/helpers/dma-resv.c @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/dma-resv.h> + +__rust_helper +int rust_helper_dma_resv_lock(struct dma_resv *obj, struct ww_acquire_ctx *ctx) +{ + return dma_resv_lock(obj, ctx); +} + +__rust_helper void rust_helper_dma_resv_unlock(struct dma_resv *obj) +{ + dma_resv_unlock(obj); +} diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c index a83060f8500c..fa56d62c9014 100644 --- a/rust/helpers/helpers.c +++ b/rust/helpers/helpers.c @@ -28,6 +28,7 @@ #include "cred.c" #include "device.c" #include "dma.c" +#include "dma-resv.c" #include "drm.c" #include "drm_gpuvm.c" #include "err.c" -- 2.53.0.959.g497ff81fa9-goog
