From: Sami Tolvanen <[email protected]> Drivers need to check whether a GEM object is PRIME-imported.
Add BaseObject::is_imported(), wrapping drm_gem_is_imported() through a C helper shim. Reviewed-by: Alice Ryhl <[email protected]> Signed-off-by: Sami Tolvanen <[email protected]> Tested-by: Deborah Brouwer <[email protected]> Reviewed-by: Daniel Almeida <[email protected]> Signed-off-by: Janne Grunau <[email protected]> --- rust/helpers/drm.c | 6 ++++++ rust/kernel/drm/gem/mod.rs | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/rust/helpers/drm.c b/rust/helpers/drm.c index 65f3f22b0e1d..8cf3ca7aeeb2 100644 --- a/rust/helpers/drm.c +++ b/rust/helpers/drm.c @@ -16,6 +16,12 @@ __rust_helper void rust_helper_drm_gem_object_put(struct drm_gem_object *obj) drm_gem_object_put(obj); } +__rust_helper bool +rust_helper_drm_gem_is_imported(const struct drm_gem_object *obj) +{ + return drm_gem_is_imported(obj); +} + __rust_helper __u64 rust_helper_drm_vma_node_offset_addr(struct drm_vma_offset_node *node) { diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs index 123a3896f2a5..3e4f5bfb5d60 100644 --- a/rust/kernel/drm/gem/mod.rs +++ b/rust/kernel/drm/gem/mod.rs @@ -210,6 +210,14 @@ fn size(&self) -> usize { unsafe { (*self.as_raw()).size } } + /// Returns whether the object's backing buffer is imported from another + /// driver. + #[inline] + fn is_imported(&self) -> bool { + // SAFETY: `self.as_raw()` is guaranteed to be a pointer to a valid `struct drm_gem_object`. + unsafe { bindings::drm_gem_is_imported(self.as_raw()) } + } + /// Creates a new handle for the object associated with a given `File` /// (or returns an existing one). /// -- 2.56.1
