Re: [PATCH v5 12/19] rust: drm: Add RegistrationGuard for drm_dev_enter/exit critical sections
From: Alexandre Courbot
Date: Thu Jul 02 2026 - 02:07:38 EST
On Sun Jun 28, 2026 at 11:53 PM JST, Danilo Krummrich wrote:
> 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@xxxxxxxxxx>
> Signed-off-by: Danilo Krummrich <dakr@xxxxxxxxxx>
Reviewed-by: Alexandre Courbot <acourbot@xxxxxxxxxx>