[PATCH 0/6] rust: drm: Higher-Ranked Lifetime private data

From: Danilo Krummrich

Date: Wed May 06 2026 - 18:10:42 EST


DRM ioctls run in process context without any guarantee that the parent
bus device is still bound. This series solves the problem by introducing
UnbindGuard -- a guard representing a drm_dev_enter/exit SRCU critical
section that proves the parent bus device is bound for the lifetime of
the guard.

On top of that, add RegistrationData as a ForLt associated type on
drm::Driver, allowing drivers to store data whose lifetime is tied to
the parent bus device binding scope. The data is allocated in
Registration::new(), lifetime-erased to 'static for storage, and made
accessible through UnbindGuard::registration_data() with the lifetime
shortened back via ForLt::cast_ref.

Also update the ioctl dispatch macro to wrap every handler in an
UnbindGuard, returning ENODEV if the device has been unplugged, and
pass both the bound parent bus device and the registration data as
arguments to handlers.

This series is based on [1], as well as Lyudes drm::DeviceContext work;
a branch with all patches can be found in [2].

[1] https://lore.kernel.org/driver-core/20260506220012.855173-1-dakr@xxxxxxxxxx/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/dakr/linux.git/log/?h=drm-lifetime

Danilo Krummrich (6):
rust: drm: Add Driver::ParentDevice associated type
rust: drm: Add UnbindGuard for drm_dev_enter/exit critical sections
rust: drm: Add RegistrationData to drm::Driver
rust: drm: Wrap ioctl dispatch in UnbindGuard
rust: drm: Pass registration data to ioctl handlers
rust: drm: Pass bound parent device to ioctl handlers

drivers/gpu/drm/nova/driver.rs | 14 +++-
drivers/gpu/drm/nova/file.rs | 8 ++
drivers/gpu/drm/tyr/driver.rs | 12 ++-
drivers/gpu/drm/tyr/file.rs | 4 +
rust/kernel/drm/device.rs | 134 ++++++++++++++++++++++++++++++++-
rust/kernel/drm/driver.rs | 100 +++++++++++++++++++-----
rust/kernel/drm/ioctl.rs | 17 ++++-
rust/kernel/drm/mod.rs | 1 +
8 files changed, 258 insertions(+), 32 deletions(-)

--
2.54.0