rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/8] DRM Rust abstractions
@ 2025-04-10 23:55 Danilo Krummrich
  2025-04-10 23:55 ` [PATCH v2 1/8] drm: drv: implement __drm_dev_alloc() Danilo Krummrich
                   ` (9 more replies)
  0 siblings, 10 replies; 40+ messages in thread
From: Danilo Krummrich @ 2025-04-10 23:55 UTC (permalink / raw)
  To: airlied, simona, maarten.lankhorst, mripard, tzimmermann, lyude,
	lina, daniel.almeida, j, alyssa
  Cc: ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh, benno.lossin,
	a.hindborg, aliceryhl, tmgross, dri-devel, rust-for-linux,
	Danilo Krummrich

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

-- 
2.49.0


^ permalink raw reply	[flat|nested] 40+ messages in thread
* [PATCH v2 0/8] DRM Rust abstractions and Nova
@ 2024-06-18 23:31 Danilo Krummrich
  2024-06-18 23:31 ` [PATCH v2 3/8] rust: drm: add driver abstractions Danilo Krummrich
  0 siblings, 1 reply; 40+ messages in thread
From: Danilo Krummrich @ 2024-06-18 23:31 UTC (permalink / raw)
  To: maarten.lankhorst, mripard, tzimmermann, airlied, daniel, ojeda,
	alex.gaynor, wedsonaf, boqun.feng, gary, bjorn3_gh, benno.lossin,
	a.hindborg, aliceryhl, lina, pstanner, ajanulgu, lyude, gregkh,
	robh, daniel.almeida
  Cc: rust-for-linux, dri-devel, nouveau, Danilo Krummrich

This patch series implements some basic DRM Rust abstractions and a stub
implementation of the Nova GPU driver.

Nova is intended to be developed upstream, starting out with just a stub driver
to lift some initial required infrastructure upstream. A more detailed
explanation can be found in [1].

This patch series is based on the "Device / Driver and PCI Rust abstractions"
series [2].

The DRM bits can also be found in [3] and the Nova bits in [4].

Changes in v2:
==============
- split up the DRM device / driver abstractions in three separate commits
- separate `struct drm_device` abstraction in a separte source file more
  cleanly
- switch `struct drm_driver` and `struct file_operations` to 'static const'
  allocations
- implement `Registration::new_foreign_owned` (using `Devres`), such that we
  don't need to keep the `Registration` alive on the Rust side, but
  automatically revoke it on device unbind
- add missing DRM driver features (Rob)
- use `module_pci_driver!` macro in Nova
- use a const sized `pci::Bar` in Nova
- increase the total amount of Documentation, rephrase some safety comments and
  commit messages for less ambiguity
- fix compilation issues with some documentation example

[1] https://lore.kernel.org/dri-devel/Zfsj0_tb-0-tNrJy@cassiopeiae/T/#u
[2] Reply to this mail titled "Device / Driver and PCI Rust abstractions".
[3] https://gitlab.freedesktop.org/drm/misc/kernel/-/tree/topic/rust-drm
[4] https://gitlab.freedesktop.org/drm/nova/-/tree/nova-next

Asahi Lina (4):
  rust: drm: ioctl: Add DRM ioctl abstraction
  rust: Add a Sealed trait
  rust: drm: file: Add File abstraction
  rust: drm: gem: Add GEM object abstraction

Danilo Krummrich (4):
  rust: drm: add driver abstractions
  rust: drm: add device abstraction
  rust: drm: add DRM driver registration
  nova: add initial driver stub

 MAINTAINERS                     |  10 +
 drivers/gpu/drm/Kconfig         |   2 +
 drivers/gpu/drm/Makefile        |   1 +
 drivers/gpu/drm/nova/Kconfig    |  12 +
 drivers/gpu/drm/nova/Makefile   |   3 +
 drivers/gpu/drm/nova/driver.rs  |  85 +++++++
 drivers/gpu/drm/nova/file.rs    |  70 ++++++
 drivers/gpu/drm/nova/gem.rs     |  50 ++++
 drivers/gpu/drm/nova/gpu.rs     | 173 ++++++++++++++
 drivers/gpu/drm/nova/nova.rs    |  18 ++
 include/uapi/drm/nova_drm.h     | 101 ++++++++
 rust/bindings/bindings_helper.h |   5 +
 rust/helpers.c                  |  23 ++
 rust/kernel/drm/device.rs       | 182 ++++++++++++++
 rust/kernel/drm/drv.rs          | 199 ++++++++++++++++
 rust/kernel/drm/file.rs         | 116 +++++++++
 rust/kernel/drm/gem/mod.rs      | 409 ++++++++++++++++++++++++++++++++
 rust/kernel/drm/ioctl.rs        | 153 ++++++++++++
 rust/kernel/drm/mod.rs          |   9 +
 rust/kernel/lib.rs              |   7 +
 rust/uapi/uapi_helper.h         |   2 +
 21 files changed, 1630 insertions(+)
 create mode 100644 drivers/gpu/drm/nova/Kconfig
 create mode 100644 drivers/gpu/drm/nova/Makefile
 create mode 100644 drivers/gpu/drm/nova/driver.rs
 create mode 100644 drivers/gpu/drm/nova/file.rs
 create mode 100644 drivers/gpu/drm/nova/gem.rs
 create mode 100644 drivers/gpu/drm/nova/gpu.rs
 create mode 100644 drivers/gpu/drm/nova/nova.rs
 create mode 100644 include/uapi/drm/nova_drm.h
 create mode 100644 rust/kernel/drm/device.rs
 create mode 100644 rust/kernel/drm/drv.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


base-commit: 6646240d29b11de3177f71ff777d0ae683c32623
-- 
2.45.1


^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2025-05-12 12:38 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-10 23:55 [PATCH v2 0/8] DRM Rust abstractions Danilo Krummrich
2025-04-10 23:55 ` [PATCH v2 1/8] drm: drv: implement __drm_dev_alloc() Danilo Krummrich
2025-04-14 13:27   ` Alyssa Rosenzweig
2025-04-18 21:00   ` Lyude Paul
2025-04-10 23:55 ` [PATCH v2 2/8] rust: drm: ioctl: Add DRM ioctl abstraction Danilo Krummrich
2025-04-14 13:54   ` Alyssa Rosenzweig
2025-04-18 21:03   ` Lyude Paul
2025-04-10 23:55 ` [PATCH v2 3/8] rust: drm: add driver abstractions Danilo Krummrich
2025-04-14 14:00   ` Alyssa Rosenzweig
2025-04-18 21:06   ` Lyude Paul
2025-04-10 23:55 ` [PATCH v2 4/8] rust: drm: add device abstraction Danilo Krummrich
2025-04-14 14:07   ` Alyssa Rosenzweig
2025-04-17 18:53   ` Lyude Paul
2025-04-17 20:20     ` Danilo Krummrich
2025-04-10 23:55 ` [PATCH v2 5/8] rust: drm: add DRM driver registration Danilo Krummrich
2025-04-14 14:11   ` Alyssa Rosenzweig
2025-04-18 21:12   ` Lyude Paul
2025-04-10 23:55 ` [PATCH v2 6/8] rust: drm: file: Add File abstraction Danilo Krummrich
2025-04-14 14:28   ` Alyssa Rosenzweig
2025-04-18 21:15   ` Lyude Paul
2025-04-10 23:55 ` [PATCH v2 7/8] rust: drm: gem: Add GEM object abstraction Danilo Krummrich
2025-04-14 15:07   ` Alyssa Rosenzweig
2025-04-17 18:42   ` Lyude Paul
2025-04-17 20:31     ` Danilo Krummrich
2025-04-17 22:33       ` Lyude Paul
2025-04-18  5:31         ` Danilo Krummrich
2025-05-12 11:41   ` Miguel Ojeda
2025-05-12 11:48     ` Miguel Ojeda
2025-05-12 12:09     ` Danilo Krummrich
2025-05-12 12:38       ` Miguel Ojeda
2025-04-10 23:55 ` [PATCH v2 8/8] MAINTAINERS: add DRM Rust source files to DRM DRIVERS Danilo Krummrich
2025-04-14 15:08   ` Alyssa Rosenzweig
2025-04-18 21:16 ` [PATCH v2 0/8] DRM Rust abstractions Lyude Paul
2025-04-24 13:59 ` Danilo Krummrich
  -- strict thread matches above, loose matches on Subject: below --
2024-06-18 23:31 [PATCH v2 0/8] DRM Rust abstractions and Nova Danilo Krummrich
2024-06-18 23:31 ` [PATCH v2 3/8] rust: drm: add driver abstractions Danilo Krummrich
2024-09-02 16:29   ` Daniel Vetter
2024-09-03 11:04     ` Asahi Lina
2024-09-03 11:11     ` Danilo Krummrich
2024-09-03 12:39       ` Simona Vetter
2024-09-04 18:30     ` Lyude Paul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).