[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1e71ad64-f5bc-2581-87b8-9bd0932a7875@gmail.com>
Date: Mon, 25 Jul 2022 13:18:56 -0700
From: Florian Fainelli <f.fainelli@...il.com>
To: Marc Zyngier <maz@...nel.org>, Bjorn Helgaas <helgaas@...nel.org>
Cc: Pali Rohár <pali@...nel.org>,
Johan Hovold <johan+linaro@...nel.org>,
Kishon Vijay Abraham I <kishon@...com>,
Xiaowei Song <songxiaowei@...ilicon.com>,
Binghui Wang <wangbinghui@...ilicon.com>,
Thierry Reding <thierry.reding@...il.com>,
Ryder Lee <ryder.lee@...iatek.com>,
Jianjun Wang <jianjun.wang@...iatek.com>,
linux-pci@...r.kernel.org,
Krzysztof Wilczyński <kw@...ux.com>,
Ley Foon Tan <ley.foon.tan@...el.com>,
linux-kernel@...r.kernel.org
Subject: Re: Why set .suppress_bind_attrs even though .remove() implemented?
On 7/24/22 02:38, Marc Zyngier wrote:
> On Fri, 22 Jul 2022 18:17:06 +0100,
> Bjorn Helgaas <helgaas@...nel.org> wrote:
>>
>> On Fri, Jul 22, 2022 at 06:06:07PM +0100, Marc Zyngier wrote:
>>> On Fri, 22 Jul 2022 15:39:05 +0100,
>>> Bjorn Helgaas <helgaas@...nel.org> wrote:
>>>>
>>>> [+cc Marc, can you clarify when we need irq_dispose_mapping()?]
>>>
>>> In general, interrupt controllers should not have to discard mappings
>>> themselves, just like they rarely create mappings themselves. That's
>>> usually a different layer that has created it (DT, for example).
>>>
>>> The problem is that these mappings persist even if the interrupt has
>>> been released by the driver (it called free_irq()), and the IRQ number
>>> can be further reused. The client driver could dispose of the mapping
>>> after having released the IRQ, but nobody does that in practice.
>>>
>>> From the point of view of the controller, there is no simple way to
>>> tell when an interrupt is "unused". And even if a driver was
>>> overzealous and called irq_dispose_mapping() on all the possible
>>> mappings (and made sure no mapping could be created in parallel), this
>>> could result in a bunch of dangling pointers should a client driver
>>> still have the interrupt requested.
>>>
>>> Fixing this is pretty hard, as IRQ descriptors are leaky (you can
>>> either have a pointer to one, or just an IRQ number -- they are
>>> strictly equivalent). So in general, being able to remove an interrupt
>>> controller driver is at best fragile, and I'm trying not to get more
>>> of this in the tree.
>>
>> Thank you!
>>
>> How do we identify an interrupt controller driver? Apparently some of
>> these PCIe controller drivers also include an interrupt controller
>> driver, but I don't know what to look for to find them.
>
> If you see a struct irq_chip somewhere, this is an interrupt
> controller. And yes, most of the PCIe RC drivers will have some sort
> of interrupt controller driver for INTx support, as well as MSI when
> the RC doesn't/cannot rely on the platform providing one.
>
> It means that these PCIe RC drivers probably shouldn't be removable if
> built as modules. Which I don't think is a big problem. You want
> modularity to reduce the size of the kernel image and only load the
> drivers the platform actually requires, saving memory in the process.
> And for something as fundamental as an interrupt controller (and PCIe
> in general), you probably want to keep it around for the lifetime of
> the machine.
No disagreement, however being able to fully remove and load the module again ensures that you bring the hardware and software in a sane state every time, i.e.: it does help find actual bugs in either implementations. It's also a faster turn around time if you are working on that specific subsystem in avoid rebooting the kernel needlessly (that puts a lot of faith into not crashing the kernel, still).
--
Florian
Powered by blists - more mailing lists