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.

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 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 
618becae72985b9dfdca8469ee48d4752fd0ca41..8d44728261ffa82fc36fa0c5df3b11a5bfb4339b
 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7467,6 +7467,7 @@ L:        [email protected]
 S:     Supported
 W:     https://rust-for-linux.com
 T:     git 
git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core.git
+F:     rust/helpers/dma-resv.c
 F:     rust/helpers/dma.c
 F:     rust/helpers/scatterlist.c
 F:     rust/kernel/dma.rs
diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helper.h
index 
dd60a5c6b142ec2c5fd6df80279ab6813163791c..ed80dd8088bc60c67b02f7666e602e33158bb962
 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 
0000000000000000000000000000000000000000..71914d8241e297511fdf7770336756c3e953a4f4
--- /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 
0943d589b7578d3c0e207937f63a5e02719c6146..aae78c938b0b5848b1740fb3f2dc4b7f93b1a760
 100644
--- a/rust/helpers/helpers.c
+++ b/rust/helpers/helpers.c
@@ -25,6 +25,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.rc1.225.gd81095ad13-goog

Reply via email to