Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: drm: gem: Add raw_dma_resv() function

For retrieving a pointer to the struct dma_resv for a given GEM object. We
also introduce it in a new trait, BaseObjectPrivate, which we automatically
implement for all gem objects and don't expose to users outside of the
crate.

Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Janne Grunau <j@jananu.net>
Tested-by: Janne Grunau <j@jannau.net>
Tested-by: Deborah Brouwer <deborah.brouwer@collabora.com>
Link: https://patch.msgid.link/20260316211646.650074-3-lyude@redhat.com
[ Fix incorrect reference in safety comment. - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>

authored by

Lyude Paul and committed by
Danilo Krummrich
89b4964c 9b836641

+12
+12
rust/kernel/drm/gem/mod.rs
··· 215 215 216 216 impl<T: IntoGEMObject> BaseObject for T {} 217 217 218 + /// Crate-private base operations shared by all GEM object classes. 219 + #[expect(unused)] 220 + pub(crate) trait BaseObjectPrivate: IntoGEMObject { 221 + /// Return a pointer to this object's dma_resv. 222 + fn raw_dma_resv(&self) -> *mut bindings::dma_resv { 223 + // SAFETY: `self.as_raw()` always returns a valid pointer to the base DRM GEM object. 224 + unsafe { (*self.as_raw()).resv } 225 + } 226 + } 227 + 228 + impl<T: IntoGEMObject> BaseObjectPrivate for T {} 229 + 218 230 /// A base GEM object. 219 231 /// 220 232 /// # Invariants