Skip to content

DRM Rust abstractions

Danilo Krummrich dri-devel rust-for-linux 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest8 patches 25 repliesIn review
  2. v18 patches 28 repliesSuperseded

Changes in v2 from the cover letter

- IOCTL: wrap data in Opaque<T> to avoid UB when creating a reference
- driver: remove unnecessary FEATURE flags
- driver: remove date field
- MAINTAINERS: add files to both DRM and DRM MISC
- change primary authorship of most patches

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8drm: drv: implement __drm_dev_alloc()drivers/gpu/drm/drm_drv.c include/drm/drm_drv.h+47 -162 replies
2/8rust: drm: ioctl: Add DRM ioctl abstractionrust/bindings/bindings_helper.h rust/kernel/drm/ioctl.rs rust/kernel/drm/mod.rs +2 more+170 -02 replies
3/8rust: drm: add driver abstractionsrust/bindings/bindings_helper.h rust/kernel/drm/driver.rs rust/kernel/drm/mod.rs+125 -02 replies
4/8rust: drm: add device abstractionrust/bindings/bindings_helper.h rust/kernel/drm/device.rs rust/kernel/drm/driver.rs +1 more+196 -73 replies
5/8rust: drm: add DRM driver registrationrust/kernel/drm/driver.rs rust/kernel/drm/mod.rs+60 -12 replies
6/8rust: drm: file: Add File abstractionrust/bindings/bindings_helper.h rust/kernel/drm/device.rs rust/kernel/drm/driver.rs +2 more+107 -22 replies
7/8rust: drm: gem: Add GEM object abstractionrust/bindings/bindings_helper.h rust/helpers/drm.c rust/helpers/helpers.c +4 more+348 -29 replies
8/8MAINTAINERS: add DRM Rust source files to DRM DRIVERSMAINTAINERS+2 -01 reply

Reviews trailers per patch

All 8 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchMaxime RipardAlyssa RosenzweigLyude Paul
SeriesR-b
1/8R-b R-b
2/8R-b
3/8R-b R-b
4/8R-b R-b
5/8R-b
6/8R-b R-b
7/8R-b
8/8R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 0/8] DRM Rust abstractions

This is the series for the initial DRM Rust abstractions, including DRM device / driver, IOCTL, File and GEM object abstractions.

Compared to the original work from Lina, the patches in this series contain the following modifications.

- "rust: drm: ioctl: Add DRM ioctl abstraction"
* wrap IOCTL data in Opaque<T> to avoid UB when creating a reference
* original source archive: https://archive.is/LqHDQ

- "rust: drm: add driver abstractions" (newly created)
* Remove unnecessary DRM features
* add #[expect(unused)] to avoid warnings
* add sealed trait
* original source archive: https://archive.is/Pl9ys

- "rust: drm: add device abstraction" (newly created)
* full rewrite of the drm::Device abstraction using the subclassing pattern
* original source archive: http://archive.today/5NxBo

- "rust: drm: add DRM driver registration" (newly created)
* move VTABLE to drm::Device to prevent use-after-free bugs; VTABLE needs to be bound to the lifetime of drm::Device, not the drm::Registration
* combine new() and register() to get rid of the registered boolean
* remove file_operations
* move struct drm_device creation to drm::Device
* introduce Devres
* original source archive: https://archive.is/Pl9ys

- "rust: drm: file: Add File abstraction"
* switch to the Opaque<T> type
* fix (mutable) references to struct drm_file (which in this context is UB)
* restructure and rename functions to align with common kernel schemes
* write and fix safety and invariant comments
* remove necessity for and convert 'as' casts
* original source archive: https://archive.is/GH8oy

- "rust: drm: gem: Add GEM object abstraction"
* 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

A full diff between this series and the original work can be found in [1].

This patch series is also available in [2]; an example usage from nova-drm can be found in [3].

[1] https://pastebin.com/qLBCfgTc
[2] https://gitlab.freedesktop.org/drm/misc/kernel/-/tree/topic/rust-drm
[3] https://gitlab.freedesktop.org/drm/nova/-/tree/staging/nova-drm

Changes in v2:
- IOCTL: wrap data in Opaque<T> to avoid UB when creating a reference
- driver: remove unnecessary FEATURE flags
- driver: remove date field
- MAINTAINERS: add files to both DRM and DRM MISC
- change primary authorship of most patches

Asahi Lina (6):
rust: drm: ioctl: Add DRM ioctl abstraction
rust: drm: add driver abstractions
rust: drm: add device abstraction
rust: drm: add DRM driver registration
rust: drm: file: Add File abstraction
rust: drm: gem: Add GEM object abstraction

Danilo Krummrich (2):
drm: drv: implement __drm_dev_alloc()
MAINTAINERS: add DRM Rust source files to DRM DRIVERS

 MAINTAINERS                     |   2 +
 drivers/gpu/drm/drm_drv.c       |  58 ++++--
 include/drm/drm_drv.h           |   5 +
 rust/bindings/bindings_helper.h |   6 +
 rust/helpers/drm.c              |  19 ++
 rust/helpers/helpers.c          |   1 +
 rust/kernel/drm/device.rs       | 195 +++++++++++++++++++
 rust/kernel/drm/driver.rs       | 170 +++++++++++++++++
 rust/kernel/drm/file.rs         |  99 ++++++++++
 rust/kernel/drm/gem/mod.rs      | 321 ++++++++++++++++++++++++++++++++
 rust/kernel/drm/ioctl.rs        | 161 ++++++++++++++++
 rust/kernel/drm/mod.rs          |  19 ++
 rust/kernel/lib.rs              |   2 +
 rust/uapi/uapi_helper.h         |   1 +
 14 files changed, 1043 insertions(+), 16 deletions(-)
 create mode 100644 rust/helpers/drm.c
 create mode 100644 rust/kernel/drm/device.rs
 create mode 100644 rust/kernel/drm/driver.rs
 create mode 100644 rust/kernel/drm/file.rs
 create mode 100644 rust/kernel/drm/gem/mod.rs
 create mode 100644 rust/kernel/drm/ioctl.rs
 create mode 100644 rust/kernel/drm/mod.rs
Signature · 1 line
2.49.0