Re: [PATCH 1/2] drm/tyr: add Wait type for GPU events

"Danilo Krummrich" <[email protected]>
Newsgroups org.kernel.vger.rust-for-linux,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
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.)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.