One of the unsolved issues we still have with the rust DRM bindings is the ability to limit certain Device operations to contexts where we can guarantee that a Device has been fully initialized and registered with userspace, or vice-versa (e.g. must be unregistered). This is a bit of an issue for KMS bindings, since we need to be able to limit the creation of static resources like CRTCs such that they only happen before userspace registration.
While the previous solution for this that I had was simply not exposing drm::Device at all until the device has been registered with userspace, unfortunately this isn't enough since: * As we found out with Tyr, drivers occasionally need to be able to create GEM objects before device registration * We would still need to be able to handle KMS callbacks which could be invoked after KMS init but before userspace registration (not handled in this series specifically, but DeviceCtx will be required for handling this). This patch series provides a pretty nice solution to this, by implementing a very similar solution to kernel::device::DeviceCtx: introducing our own DeviceCtx type state. In the future, we'll likely add a DeviceCtx state specifically for KMS devices that aren't guaranteed to be registered with userspace. Lyude Paul (2): rust: drm: Introduce DeviceCtx rust/drm/gem: Use DeviceCtx with GEM objects drivers/gpu/drm/nova/driver.rs | 10 +- drivers/gpu/drm/nova/gem.rs | 11 +- drivers/gpu/drm/tyr/driver.rs | 15 ++- drivers/gpu/drm/tyr/gem.rs | 3 +- rust/kernel/drm/device.rs | 181 ++++++++++++++++++++++++++------- rust/kernel/drm/driver.rs | 37 +++++-- rust/kernel/drm/gem/mod.rs | 66 ++++++++---- rust/kernel/drm/mod.rs | 4 + 8 files changed, 244 insertions(+), 83 deletions(-) base-commit: ade19c5060dfa39b84a9475a4a6b05e2a8a2b3ac -- 2.51.1
