[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aECXCGVaVNt7lQ0J@cassiopeiae>
Date: Wed, 4 Jun 2025 20:57:12 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: Daniel Almeida <daniel.almeida@...labora.com>
Cc: Alice Ryhl <aliceryhl@...gle.com>, Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>,
Trevor Gross <tmgross@...ch.edu>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org
Subject: Re: [PATCH v3 1/2] rust: irq: add support for request_irq()
On Wed, Jun 04, 2025 at 03:32:16PM -0300, Daniel Almeida wrote:
> So, what is the result of this discussion?
>
> > On 3 Jun 2025, at 07:16, Danilo Krummrich <dakr@...nel.org> wrote:
> >
> > On Tue, Jun 03, 2025 at 12:09:05PM +0200, Danilo Krummrich wrote:
> >> Yes, we could solve this with a lock as well, but it would be an additional
> >> lock, just to maintain the current drop() semantics, which I don't see much
> >> value in.
> >
> > If we want to keep the current drop() semantics we could use a completion
> > instead.
> >
> > // Devres::drop()
> > revoke_nosync()
> > complete()
> >
> > // devres_callback
> > if !try_revoke() {
> > // we end up here if try_revoke() indicates that the object was
> > // revoked already
> > wait_for_completion()
> > }
>
> This looks like what is going on here [0], so should I implement what Alice suggested? i.e.:
>
> > > Based on this, we could imagine something along these lines:
> > >
> > > struct RegistrationInner(i32);
> > > impl Drop for RegistrationInner {
> > > fn drop(&mut self) {
> > > free_irq(...);
> > > }
> > > }
> > >
> > > struct Registration<T> {
> > > reg: Devres<RegistrationInner>,
> > > data: T,
> > > }
> > >
> > > Here you can access the `data` on the registration at any time without
> > > synchronization.
Yes, I think that's the best approach. You can also have a look at [1], which
implements this approach for misc device already, even though it's slightly more
complicated.
[1] https://lore.kernel.org/lkml/20250530142447.166524-6-dakr@kernel.org/
>
> — Daniel
>
> [0] https://lore.kernel.org/rust-for-linux/CANiq72nfOcOGJuktzSpNAUWwekaZ98JL7c1FhMKCjPSG80JMPA@mail.gmail.com/T/#t
Powered by blists - more mailing lists