Re: [PATCH v2 2/2] rust: workqueue: add creation of workqueues
From: Danilo Krummrich
Date: Thu Nov 13 2025 - 16:55:18 EST
On Thu Nov 13, 2025 at 9:01 PM AEDT, Alice Ryhl wrote:
> Creating workqueues is needed by various GPU drivers.
Indeed, and of course lots of other drivers need this as well. :)
> Not only does it give you better control over execution, it also allows
> devices to ensure that all tasks have exited before the device is unbound (or
> similar) by running the workqueue destructor.
Exactly, but for this case we should fence the workqueue with devres, such that
we can guarantee a scope for a &Device<Bound> for all work items scheduled on
such a workqueue, i.e. provide a &Device<Bound> in run().
Otherwise drivers have to either access device resources with try_access() or
get themselves a &Device<Bound> with the unsafe Device::as_bound() method from
within the run() callback.