lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1FCFF2CD-9CF1-4716-AFDA-78A5AFAF113F@collabora.com>
Date: Mon, 2 Jun 2025 11:40:43 -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>,
 Benno Lossin <benno.lossin@...ton.me>,
 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>,
 linux-kernel@...r.kernel.org,
 rust-for-linux@...r.kernel.org
Subject: Re: [PATCH v3 1/2] rust: irq: add support for request_irq()

Danilo,

> On 15 May 2025, at 10:52, Danilo Krummrich <dakr@...nel.org> wrote:
> 
> On Thu, May 15, 2025 at 03:45:28PM +0200, Danilo Krummrich wrote:
>> On Thu, May 15, 2025 at 10:16:33AM -0300, Daniel Almeida wrote:
>>> 
>>>>> 
>>>>> Well, not really, because this impl PinInit can be assigned to something larger
>>>>> that is already pinned, like drm::Device::Data for example, which is (or was)
>>>>> already behind an Arc, or any other private data in other subsystems.
>>>>> 
>>>>> IIUC what you proposed has yet another indirection. If we reuse the example
>>>>> from above, that would be an Arc for the drm Data, and another Arc for the
>>>>> handler itself?
>>>> 
>>>> Can't you implement Handler for drm::Device::Data and e.g. make Registration
>>>> take an Arc<T: Handler>?
>>> 
>>> No, because drivers may need more than one handler. Panthor needs 3, for
>>> example, for 3 different lines.
>>> 
>>>> 
>>>> The irq::Registration itself doesn't need to be allocated dynamically, so it'd
>>>> still be a single allocation, no?
>>>> 
>>> 
>>> Right, the registrations don't, but the handlers do.
>> 
>> Why does the handler need to be allocated dynamically?
>> 
>> What about something like the following?
>> 
>> pub struct Registration<T, H: Handler<T>> { ... };
>> 
>> pub trait Handler<T> {
>>   fn handle_irq(&T) -> IrqReturn;
>> }
>> 
>> // Could be `drm::Device::Data`.
>> struct MyData { ... };
>> 
>> // Implements `Handler<MyData>`.
>> struct IRQHandler1;
>> struct IRQHandler2;
>> 
>> // `data` is `Arc<MyData>`
>> irq::Registration::<IRQHandler1>::new(data, ...);
>> irq::Registration::<IRQHandler2>::new(data, ...);
>> 
>> With that you can have as many IRQs as you want without any additional
>> allocation.
> 
> Alternatively we could also do the following, which is probably simpler.
> 
> pub struct Registration<H: Handler> { ... };
> 
> pub trait Handler {
>   fn handle_irq(&self) -> IrqReturn;
> }
> 
> // Could be `drm::Device::Data`.
> struct MyData { ... };
> 
> // Implements `Handler`.
> struct IRQHandler1(Arc<MyData>);
> struct IRQHandler2(Arc<MyData>);
> 
> // `data` is `Arc<MyData>`
> let handler1 = IRQHandler1::new(data);
> let handler2 = IRQHandler2::new(data);
> 
> irq::Registration::new(handler1, ...);
> irq::Registration::new(handler2, ...);
> 

I am trying to implement this, but isn't this what we have already?

I guess the only difference would be removing the handler() accessor, as the
caller is now expected to figure this part out on his own, i.e.:

In your example (IIUC) that would mean accessing the Arc in IRQHandler1
and IRQHandler2 through some other clone and from the actual T:Handler in
the callback.

— Daniel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ