Re: [PATCH 1/2] drm/tyr: add Wait type for GPU events
From: Danilo Krummrich
Date: Tue Jul 21 2026 - 11:34:22 EST
On Tue Jul 21, 2026 at 5:14 PM CEST, Laura Nao wrote:
> +/// A convenience type to wait for GPU events.
> +///
> +/// Wraps a [`CondVar`] and [`Mutex`] pair. The mutex synchronizes predicate checks
> +/// with wait/wake operations; the condvar provides the sleep/wake mechanism.
> +#[pin_data]
> +pub(crate) struct Wait {
> + /// The actual wait/signal mechanism.
> + #[pin]
> + cond: CondVar,
> + /// Synchronizes waiters with notifications.
> + #[pin]
> + lock: Mutex<()>,
> +}
This is backwards; if I get this right at a quick glance it is basically abusing
CondVar to implement a WaitQueue abstraction in your driver.
What you actually seem to look for is a proper WaitQueue abstraction, which
could then also be used to simplify the implementation of CondVar.
I'm already working on a WaitQueue abstraction, since I need it elsewhere. I can
probably post something in a few days.
(I didn't check your use-case but you may want to consider completions and
simple waitqueue as well.)