Lines Matching +full:reference +full:- +full:sync

1 // SPDX-License-Identifier: GPL-2.0 OR MIT
22 sync::aref::{
50 unsafe impl $( <$( $tparam_id ),+> )? $crate::sync::aref::AlwaysRefCounted for $type
56 // SAFETY: The existence of a shared reference guarantees that the refcount is
57 // non-zero.
65 // SAFETY: The safety requirements guarantee that the refcount is non-zero.
88 pub trait DriverObject: Sync + Send + Sized {
100 ) -> impl PinInit<Self, Error>;
103 fn open(_obj: &DriverAllocImpl<Self>, _file: &DriverFile<Self>) -> Result {
113 /// Returns a reference to the raw `drm_gem_object` structure, which must be valid as long as
115 fn as_raw(&self) -> *mut bindings::drm_gem_object;
117 /// Converts a pointer to a `struct drm_gem_object` into a reference to `Self`.
121 /// - `self_ptr` must be a valid pointer to `Self`.
122 /// - The caller promises that holding the immutable reference returned by this function does
124 unsafe fn from_raw<'a>(self_ptr: *mut bindings::drm_gem_object) -> &'a Self;
130 ) -> core::ffi::c_int {
162 fn as_raw(&self) -> *mut bindings::drm_gem_object {
166 unsafe fn from_raw<'a>(self_ptr: *mut bindings::drm_gem_object) -> &'a Self {
176 fn size(&self) -> usize {
183 fn create_handle<D, F>(&self, file: &drm::File<F>) -> Result<u32>
198 fn lookup_handle<D, F>(file: &drm::File<F>, handle: u32) -> Result<ARef<Self>>
211 // - A `drm::Driver` can only have a single `File` implementation.
212 // - `file` uses the same `drm::Driver` as `Self`.
213 // - Therefore, we're guaranteed that `ptr` must be a gem object embedded within `Self`.
214 // - And we check if the pointer is null befoe calling from_raw(), ensuring that `ptr` is a
219 // - We take ownership of the reference of `drm_gem_object_lookup()`.
220 // - Our `NonNull` comes from an immutable reference, thus ensuring it is a valid pointer to
226 fn create_mmap_offset(&self) -> Result<u64> {
237 /// Crate-private base operations shared by all GEM object classes.
241 fn raw_dma_resv(&self) -> *mut bindings::dma_resv {
257 pub struct Object<T: DriverObject + Send + Sync, Ctx: DeviceContext = Registered> {
288 ) -> Result<ARef<Self>> {
292 data <- T::new(dev, size, args),
321 // SAFETY: We take over the initial reference count from `drm_gem_object_init()`.
326 pub fn dev(&self) -> &drm::Device<T::Driver, Ctx> {
328 // - `struct drm_gem_object.dev` is initialized and valid for as long as the GEM
330 // - The device we used for creating the gem object is passed as &drm::Device<T::Driver> to
333 // - Any type invariants of `Ctx` are upheld by using the same `Ctx` for the `Device` we
338 fn as_raw(&self) -> *mut bindings::drm_gem_object {
371 fn deref(&self) -> &Self::Target {
390 pub(super) const fn create_fops(owner: *mut bindings::module) -> bindings::file_operations {