[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DBB0NXU86D6G.2M3WZMS2NUV10@kernel.org>
Date: Sun, 13 Jul 2025 17:02:08 +0200
From: "Danilo Krummrich" <dakr@...nel.org>
To: "Daniel Almeida" <daniel.almeida@...labora.com>
Cc: "Benno Lossin" <lossin@...nel.org>, "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>, "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 v6 3/6] rust: irq: add support for non-threaded IRQs and
handlers
On Sun Jul 13, 2025 at 4:48 PM CEST, Daniel Almeida wrote:
>
>
>> On 13 Jul 2025, at 11:27, Danilo Krummrich <dakr@...nel.org> wrote:
>>
>> On Sun Jul 13, 2025 at 4:19 PM CEST, Danilo Krummrich wrote:
>>> On Sun Jul 13, 2025 at 4:09 PM CEST, Daniel Almeida wrote:
>>>> On a second look, I wonder how useful this will be.
>>>>
>>>> fn handle(&self, dev: &Device<Bound>) -> IrqReturn
>>>>
>>>> Sorry for borrowing this terminology, but here we offer Device<Bound>, while I
>>>> suspect that most drivers will be looking for the most derived Device type
>>>> instead. So for drm drivers this will be drm::Device, for example, not the base
>>>> dev::Device type. I assume that this pattern will hold for other subsystems as
>>>> well.
>>>>
>>>> Which brings me to my second point: drivers can store an ARef<drm::Device> on
>>>> the handler itself, and I assume that the same will be possible in other
>>>> subsystems.
>>>
>>> Well, the whole point is that you can use a &Device<Bound> to directly access
>>> device resources without any overhead, i.e.
>>>
>>> fn handle(&self, dev: &Device<Bound>) -> IrqReturn {
>>> let io = self.iomem.access(dev);
>>>
>>> io.write32(...);
>>> }
>>
>> So, yes, you can store anything in your handler, but the &Device<Bound> is a
>> cookie for the scope.
>
> Fine, but can’t you get a &Device<Bound> from a ARef<drm::Device>, for example?
> Perhaps a nicer solution would be to offer this capability instead?
I think you're confusing quite some things here.
(1) I'm talking about the bus device the IRQ is registered for (e.g. PCI,
platform, etc.). drm::Device represents a class device, which do not
have DeviceContext states, such as Bound.
(2) Owning a reference count of a device (i.e. ARef<Device>) does *not*
guarantee that the device is bound. You can own a reference count to the
device object way beyond it being bound. Instead, the guarantee comes from
the scope.
In this case, the scope is the IRQ callback, since the irq::Registration
guarantees to call and complete free_irq() before the underlying bus
device is unbound.
Powered by blists - more mailing lists