Files
linux/rust/kernel/drm/mod.rs
Danilo Krummrich 2455d5f2d5 rust: drm: Add RegistrationGuard for drm_dev_enter/exit critical sections
DRM ioctls do not guarantee that the parent bus device is still bound.
However, since DRM device registration is managed through Devres, using
drm_dev_unplug() on unregistration ensures that between drm_dev_enter()
and drm_dev_exit() the parent device must be bound.

Add RegistrationGuard, a guard object representing a drm_dev_enter/exit
SRCU critical section that dereferences to &Device<T, Registered>. The
guard is obtained from Device<T, Ioctl> and proves at runtime that the
device is still registered.

Switch Registration::drop from drm_dev_unregister() to drm_dev_unplug()
to provide the SRCU barrier that RegistrationGuard's safety argument
relies on.

Reviewed-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Tested-by: Deborah Brouwer <deborah.brouwer@collabora.com>
Link: https://patch.msgid.link/20260628145406.2107056-13-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2026-07-12 15:56:52 +02:00

27 lines
588 B
Rust

// SPDX-License-Identifier: GPL-2.0 OR MIT
//! DRM subsystem abstractions.
pub mod device;
pub mod driver;
pub mod file;
pub mod gem;
pub mod gpuvm;
pub mod ioctl;
pub use self::device::Device;
pub use self::device::DeviceContext;
pub use self::device::Ioctl;
pub use self::device::Normal;
pub use self::device::Registered;
pub use self::device::RegistrationGuard;
pub use self::device::UnregisteredDevice;
pub use self::driver::Driver;
pub use self::driver::DriverInfo;
pub use self::driver::Registration;
pub use self::file::File;
pub(crate) mod private {
pub trait Sealed {}
}