[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aFA8HLREfMtZSh_u@pollux>
Date: Mon, 16 Jun 2025 17:45:32 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: Daniel Almeida <daniel.almeida@...labora.com>
Cc: 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>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Benno Lossin <lossin@...nel.org>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Krzysztof Wilczyński <kwilczynski@...nel.org>,
linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org,
linux-pci@...r.kernel.org
Subject: Re: [PATCH v4 4/6] rust: irq: add support for threaded IRQs and
handlers
On Mon, Jun 16, 2025 at 10:48:37AM -0300, Daniel Almeida wrote:
> Hi Danilo,
>
> > On 9 Jun 2025, at 13:24, Daniel Almeida <daniel.almeida@...labora.com> wrote:
> >
> > Hi Danilo,
> >
> >> On 9 Jun 2025, at 09:27, Danilo Krummrich <dakr@...nel.org> wrote:
> >>
> >> On Sun, Jun 08, 2025 at 07:51:09PM -0300, Daniel Almeida wrote:
> >>> +/// Callbacks for a threaded IRQ handler.
> >>> +pub trait ThreadedHandler: Sync {
> >>> + /// The actual handler function. As usual, sleeps are not allowed in IRQ
> >>> + /// context.
> >>> + fn handle_irq(&self) -> ThreadedIrqReturn;
> >>> +
> >>> + /// The threaded handler function. This function is called from the irq
> >>> + /// handler thread, which is automatically created by the system.
> >>> + fn thread_fn(&self) -> IrqReturn;
> >>> +}
> >>> +
> >>> +impl<T: ?Sized + ThreadedHandler + Send> ThreadedHandler for Arc<T> {
> >>> + fn handle_irq(&self) -> ThreadedIrqReturn {
> >>> + T::handle_irq(self)
> >>> + }
> >>> +
> >>> + fn thread_fn(&self) -> IrqReturn {
> >>> + T::thread_fn(self)
> >>> + }
> >>> +}
> >>
> >> In case you intend to be consistent with the function pointer names in
> >> request_threaded_irq(), it'd need to be handler() and thread_fn(). But I don't
> >> think there's a need for that, both aren't really nice for names of trait
> >> methods.
> >>
> >> What about irq::Handler::handle() and irq::Handler::handle_threaded() for
> >> instance?
> >>
> >> Alternatively, why not just
> >>
> >> trait Handler {
> >> fn handle(&self);
> >> }
> >>
> >> trait ThreadedHandler {
> >> fn handle(&self);
> >> }
> >>
> >> and then we ask for `T: Handler + ThreadedHandler`.
> >
> > Sure, I am totally OK with renaming things, but IIRC I've tried Handler +
> > ThreadedHandler in the past and found it to be problematic. I don't recall why,
> > though, so maybe it's worth another attempt.
>
> Handler::handle() returns IrqReturn and ThreadedHandler::handle() returns
> ThreadedIrqReturn, which includes WakeThread, so these had to be separate
> traits.
Ok, that fine then. But I'd still prefer the better naming as mentioned above.
Powered by blists - more mailing lists