From: Marc Zyngier <maz@kernel.org>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Jonathan Hunter <jonathanh@nvidia.com>,
Dmitry Osipenko <digetx@gmail.com>,
Sowjanya Komatineni <skomatineni@nvidia.com>,
Venkat Reddy Talla <vreddytalla@nvidia.com>,
Thomas Gleixner <tglx@linutronix.de>,
kernel-team@android.com
Subject: Re: [PATCH 3/3] soc/tegra: pmc: Don't create fake interrupt hierarchy levels
Date: Mon, 05 Oct 2020 14:10:13 +0100 [thread overview]
Message-ID: <f5b711ff9289d41f25b0ea3b6658651f@kernel.org> (raw)
In-Reply-To: <20201005113335.GT425362@ulmo>
On 2020-10-05 12:33, Thierry Reding wrote:
> On Mon, Oct 05, 2020 at 12:14:43PM +0100, Marc Zyngier wrote:
>> The Tegra PMC driver does ungodly things with the interrupt hierarchy,
>> repeatedly corrupting it by pulling hwirq numbers out of thin air,
>> overriding existing IRQ mappings and changing the handling flow
>> of unsuspecting users.
>>
>> All of this is done in the name of preserving the interrupt hierarchy
>> even when these levels do not exist in the HW. Together with the use
>> of proper IRQs for IPIs, this leads to an unbootable system as the
>> rescheduling IPI gets repeatedly repurposed for random drivers...
>>
>> Instead, let's allow the hierarchy to be trimmed to the level that
>> actually makes sense for the HW, and not any deeper. This avoids
>> having unnecessary callbacks, overriding mappings, and otherwise
>> keeps the hierarchy sane.
>>
>> Signed-off-by: Marc Zyngier <maz@kernel.org>
>> ---
>> drivers/soc/tegra/pmc.c | 79
>> +++++++++++++++--------------------------
>> 1 file changed, 29 insertions(+), 50 deletions(-)
>>
>> diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
>> index 9960f7c18431..4eea3134fb3e 100644
>> --- a/drivers/soc/tegra/pmc.c
>> +++ b/drivers/soc/tegra/pmc.c
>> @@ -1993,6 +1993,30 @@ static int tegra_pmc_irq_translate(struct
>> irq_domain *domain,
>> return 0;
>> }
>>
>> +/* Trim the irq hierarchy from a particular irq domain */
>> +static void trim_hierarchy(unsigned int virq, struct irq_domain
>> *domain)
>> +{
>> + struct irq_data *tail, *irq_data = irq_get_irq_data(virq);
>> +
>> + /* The PMC doesn't generate any interrupt by itself */
>> + if (WARN_ON(!irq_data->parent_data))
>> + return;
>> +
>> + /* Skip until we find the right domain */
>> + while (irq_data->parent_data && irq_data->parent_data->domain !=
>> domain)
>> + irq_data = irq_data->parent_data;
>> +
>> + /* Sever the inner part of the hierarchy... */
>> + tail = irq_data->parent_data;
>> + irq_data->parent_data = NULL;
>> +
>> + /* ... and free it */
>> + for (irq_data = tail; irq_data; irq_data = tail) {
>> + tail = irq_data->parent_data;
>> + kfree(irq_data);
>> + };
>> +}
>
> That kind of looks like what I originally wanted to do and (naively)
> thought that passing the (0, NULL, NULL) triplet would achieve.
>
> Given that this is fairly low-level stuff that deals with the inner
> workings of the IRQ infrastructure, should we eventually pull this out
> of the driver and make it into a core helper? I don't seriously expect
> this to be widely useful, but putting it into the core might help keep
> it more maintainable.
That's the ultimate plan, but I wanted to give it some soaking time
on Tegra before exposing it to the outside world
(irq_domain_free_irq_data()
could be rewritten in terms of this primitive, for example).
> I volunteer to do that work if you think it's a good idea.
Sure, once we know we're good to go with this.
Thanks,
M.
--
Jazz is not dead. It just smells funny...
next prev parent reply other threads:[~2020-10-05 13:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-05 11:14 [PATCH 0/3] soc/tegra: Prevent the PMC driver from corrupting interrupt routing Marc Zyngier
2020-10-05 11:14 ` [PATCH 1/3] gpio: tegra186: Allow optional irq parent callbacks Marc Zyngier
2020-10-05 11:14 ` [PATCH 2/3] soc/tegra: pmc: " Marc Zyngier
2020-10-05 11:27 ` Thierry Reding
2020-10-05 12:59 ` Marc Zyngier
2020-10-05 11:14 ` [PATCH 3/3] soc/tegra: pmc: Don't create fake interrupt hierarchy levels Marc Zyngier
2020-10-05 11:33 ` Thierry Reding
2020-10-05 13:10 ` Marc Zyngier [this message]
2020-10-05 11:22 ` [PATCH 0/3] soc/tegra: Prevent the PMC driver from corrupting interrupt routing Thierry Reding
2020-10-05 13:06 ` Marc Zyngier
2020-10-05 15:45 ` Thierry Reding
2020-10-05 18:23 ` Jon Hunter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f5b711ff9289d41f25b0ea3b6658651f@kernel.org \
--to=maz@kernel.org \
--cc=digetx@gmail.com \
--cc=jonathanh@nvidia.com \
--cc=kernel-team@android.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=skomatineni@nvidia.com \
--cc=tglx@linutronix.de \
--cc=thierry.reding@gmail.com \
--cc=vreddytalla@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).