Re: [PATCH 1/2] drm/tyr: add Wait type for GPU events
From: Laura Nao
Date: Mon Jul 27 2026 - 05:06:11 EST
Hi Danilo,
On 7/21/26 17:32, Danilo Krummrich wrote:
> 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.)
I noticed the WaitQueue abstraction has now been sent on the ML [1].
I'll start reworking this series to work on top of that.
Thanks for the feedback/pointers!
Best,
Laura
[1] https://lore.kernel.org/rust-for-linux/20260726223613.1242940-1-dakr@xxxxxxxxxx/