Re: [PATCH 2/6] rust: drm: Add UnbindGuard for drm_dev_enter/exit critical sections

From: Gary Guo

Date: Wed May 27 2026 - 15:50:39 EST


On Wed May 27, 2026 at 2:03 AM BST, Alistair Popple wrote:
> On 2026-05-26 at 16:17 +1000, Alistair Popple <apopple@xxxxxxxxxx> wrote...
>> On 2026-05-07 at 08:06 +1000, Danilo Krummrich <dakr@xxxxxxxxxx> 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 UnbindGuard, a guard object representing a drm_dev_enter/exit SRCU
>> > critical section that dereferences to &Device<Bound> of the parent bus
>> > device. The guard is only available on Device<T, Registered>, ensuring
>> > it cannot be used on unregistered devices.
>> >
>> > Also add with_unbind_guard() as a convenience helper that executes a
>> > closure with the bound device reference.
>> >
>> > Switch Registration::drop from drm_dev_unregister() to drm_dev_unplug()
>> > to provide the SRCU barrier that UnbindGuard's safety argument relies on.
>>
>> I don't (yet) claim to be a Rust-for-Linux expert but reading through this made
>> sense to me and it's been useful for some Nova development so feel free to add:
>>
>> Reviewed-by: Alistair Popple <apopple@xxxxxxxxxx>
>>
>> for whatever that is worth :-)
>
> Which is definitely not much :) I just realised this has been replaced by a more
> recent version of this series with 24 patches, so will use that instead.

Are you talking about
https://lore.kernel.org/rust-for-linux/20260525202921.124698-1-dakr@xxxxxxxxxx?
That's for driver-core, this is for DRM.

Best,
Gary