[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <B4E43744-D3F5-4720-BC75-29C092BAF7A6@collabora.com>
Date: Mon, 16 Jun 2025 10:48:37 -0300
From: Daniel Almeida <daniel.almeida@...labora.com>
To: Danilo Krummrich <dakr@...nel.org>
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
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.
I'd say lets keep it this way. This really looks like the discussion on
de-duplicating code, and as I said (IMHO) it just complicates the
implementation for no gain.
— Daniel
Powered by blists - more mailing lists