[RFC PATCH 2/9] rust: drm: gem: add method to return DmaResv from GEMObject

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A GEMObject, related to struct drm_gem_object, holds a pointer
to reservation object associated with the this GEM object. Therefore,
expose this reservation object through the DmaResv safe abstraction.

Signed-off-by: Maíra Canal <mcanal@xxxxxxxxxx>
---
 rust/kernel/drm/gem/mod.rs | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
index c4a42bb2f718..dae95e5748a7 100644
--- a/rust/kernel/drm/gem/mod.rs
+++ b/rust/kernel/drm/gem/mod.rs
@@ -11,6 +11,7 @@ use alloc::boxed::Box;
 
 use crate::{
     bindings,
+    dma_resv::DmaResv,
     drm::{device, drv, file},
     error::{to_result, Result},
     prelude::*,
@@ -136,6 +137,12 @@ pub trait BaseObject: IntoGEMObject {
         self.gem_obj().size
     }
 
+    /// Returns the pointer to reservation object associated with this GEM object.
+    fn resv(&self) -> DmaResv {
+        // SAFETY: Every GEM object holds a reference to a reservation object
+        unsafe { DmaResv::from_raw(self.gem_obj().resv) }
+    }
+
     /// Sets the exportable flag, which controls whether the object can be exported via PRIME.
     fn set_exportable(&mut self, exportable: bool) {
         self.mut_gem_obj().exportable = exportable;
-- 
2.39.2




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux