diff options
| author | 2025-04-11 01:55:26 +0200 | |
|---|---|---|
| committer | 2025-04-28 10:08:23 +0200 | |
| commit | c284d3e423382be3591d5b1e402e330e6c3f726c (patch) | |
| tree | 965a13ac0a22001bf864e3512ce70467a2a560b1 /rust/kernel/drm/device.rs | |
| parent | rust: drm: file: Add File abstraction (diff) | |
| download | wireguard-linux-c284d3e423382be3591d5b1e402e330e6c3f726c.tar.xz wireguard-linux-c284d3e423382be3591d5b1e402e330e6c3f726c.zip | |
rust: drm: gem: Add GEM object abstraction
DRM GEM is the DRM memory management subsystem used by most modern
drivers; add a Rust abstraction for DRM GEM.
This includes the BaseObject trait, which contains operations shared by
all GEM object classes.
Signed-off-by: Asahi Lina <lina@asahilina.net>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Link: https://lore.kernel.org/r/20250410235546.43736-8-dakr@kernel.org
[ Rework of GEM object abstractions
* switch to the Opaque<T> type
* fix (mutable) references to struct drm_gem_object (which in this
context is UB)
* drop all custom reference types in favor of AlwaysRefCounted
* bunch of minor changes and simplifications (e.g. IntoGEMObject
trait)
* write and fix safety and invariant comments
* remove necessity for and convert 'as' casts
* original source archive: https://archive.is/dD5SL
- Danilo ]
[ Fix missing CONFIG_DRM guards in rust/helpers/drm.c. - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'rust/kernel/drm/device.rs')
| -rw-r--r-- | rust/kernel/drm/device.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/rust/kernel/drm/device.rs b/rust/kernel/drm/device.rs index 520f51bb40af..74c9a3dd719e 100644 --- a/rust/kernel/drm/device.rs +++ b/rust/kernel/drm/device.rs @@ -89,9 +89,11 @@ impl<T: drm::Driver> Device<T> { driver_features: drm::driver::FEAT_GEM, ioctls: T::IOCTLS.as_ptr(), num_ioctls: T::IOCTLS.len() as i32, - fops: core::ptr::null_mut() as _, + fops: &Self::GEM_FOPS as _, }; + const GEM_FOPS: bindings::file_operations = drm::gem::create_fops(); + /// Create a new `drm::Device` for a `drm::Driver`. pub fn new(dev: &device::Device, data: impl PinInit<T::Data, Error>) -> Result<ARef<Self>> { // SAFETY: |
