Skip to content

lifetime-parameterized DRM File private data

Danilo Krummrich dri-devel lkml nova-gpu rust-for-linux 3 versions – Applied

Status from this message: Applied, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest7 patches 4 repliesApplied
  2. v27 patches 12 repliesSuperseded
  3. v17 patches 16 repliesSuperseded

Changes in v3 from the cover letter

- Move the DriverFile bound to Driver::File<'a>.
- Require Send + Sync for DriverFile.
- Use Atomic<u64> for open_count.
- Explain driver_priv synchronization in postclose_callback().

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/7rust: drm: rename Ioctl device context to Userspacerust/kernel/drm/device.rs rust/kernel/drm/ioctl.rs rust/kernel/drm/mod.rs+19 -160 replies
2/7rust: drm: gem: gate open/close callbacks with RegistrationGuardrust/kernel/drm/gem/mod.rs+16 -00 replies
3/7rust: drm: move file_operations from gem to devicerust/kernel/drm/device.rs rust/kernel/drm/gem/mod.rs+20 -230 replies
4/7rust: fs: add iminor() helperrust/helpers/fs.c+5 -01 reply
5/7rust: drm: wrap fops open with RegistrationGuardrust/kernel/drm/device.rs+62 -10 replies
6/7rust: drm: return impl PinInit from DriverFile::open()drivers/gpu/drm/nova/file.rs drivers/gpu/drm/tyr/file.rs rust/kernel/drm/file.rs +1 more+9 -90 replies
7/7rust: drm: make Driver::File lifetime-parameterizeddrivers/gpu/drm/nova/driver.rs drivers/gpu/drm/nova/file.rs drivers/gpu/drm/nova/gem.rs +8 more+322 -902 replies

Reviews trailers per patch

All 7 patches have a Reviewed-by or Acked-by.

PatchAlice RyhlDaniel AlmeidaGary GuoChristian Brauner
1/7R-b R-b R-b
2/7R-b R-b R-b
3/7R-b R-b R-b
4/7R-b R-b R-b A-b
5/7R-b R-b R-b
6/7R-b R-b R-b
7/7R-b R-b R-b R-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 4 reviewers.

Read the v3 thread

Cover letter [PATCH v3 0/7] lifetime-parameterized DRM File private data

DRM file private data is currently 'static, preventing drivers from borrowing registration-scoped resources in their per-file state. This series makes Driver::File lifetime-parameterized, so file data can borrow from RegistrationData.

File data is guaranteed to be dropped before registration data, either when the file is closed normally or when the device is unregistered, whichever comes first. To enforce this during unbind, Registration::drop() revokes all open file data and waits for its destruction before dropping registration data.

fops.open is wrapped in a RegistrationGuard (drm_dev_enter/exit) so that after drm_dev_unplug() all successfully opened files are accounted for. GEM open/close callbacks are similarly gated to prevent access to stale file data after unbind.

The series is based on drm-rust-next with [1] applied; a branch with the patches is available in [2].

[1] https://lore.kernel.org/all/[email protected]/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/dakr/linux.git/log/?h=drm/file

Changes in v3:
- Move the DriverFile bound to Driver::File<'a>.
- Require Send + Sync for DriverFile.
- Use Atomic<u64> for open_count.
- Explain driver_priv synchronization in postclose_callback().

Changes in v2:
- Replace ForLt with Driver::File<'a>; use inner_with() for file-data access and allow returning borrowed fields.
- Use Opaque<bindings::drm_file> during teardown.
- Drop file data outside filelist_mutex; also clean up file data on registration failure.
- Reject cross-device GEM handles.
- Clarify safety documentation and add inline annotations.

Danilo Krummrich (7):
rust: drm: rename Ioctl device context to Userspace
rust: drm: gem: gate open/close callbacks with RegistrationGuard
rust: drm: move file_operations from gem to device
rust: fs: add iminor() helper
rust: drm: wrap fops open with RegistrationGuard
rust: drm: return impl PinInit from DriverFile::open()
rust: drm: make Driver::File lifetime-parameterized

 drivers/gpu/drm/nova/driver.rs |   2 +-
 drivers/gpu/drm/nova/file.rs   |  16 +--
 drivers/gpu/drm/nova/gem.rs    |   8 +-
 drivers/gpu/drm/tyr/driver.rs  |   2 +-
 drivers/gpu/drm/tyr/file.rs    |  13 ++-
 rust/helpers/fs.c              |   5 +
 rust/kernel/drm/device.rs      | 136 ++++++++++++++++++++++----
 rust/kernel/drm/driver.rs      | 113 ++++++++++++++++++++--
 rust/kernel/drm/file.rs        | 172 ++++++++++++++++++++++++---------
 rust/kernel/drm/gem/mod.rs     |  80 +++++++++------
 rust/kernel/drm/gem/shmem.rs   |  11 ++-
 rust/kernel/drm/ioctl.rs       |  18 ++--
 rust/kernel/drm/mod.rs         |   2 +-
 13 files changed, 446 insertions(+), 132 deletions(-)

base-commit: 23eb2cfcf15209d149f407e462704c21b9ce9cc4

Signature · 1 line
2.56.1