From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D75E7C4363A for ; Mon, 5 Oct 2020 13:11:47 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6970F206DD for ; Mon, 5 Oct 2020 13:11:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HqfKUrAK"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="r9K6pmsQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6970F206DD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-ID:References:In-Reply-To:Subject:To:From: Date:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=IVPcl9SCl1G3gVoNO0n07rYXfhihU7tHd4VjSxD+ws4=; b=HqfKUrAKEgYgKYStfnOz7I6fA b8aSBwpdbZpIAZ2bp9Sng+eo1AYlRHjyJSzigfFpv08+ttyidet+D91jr7P1/LPH3l3HQvJ4klhzG 6+QzVx+pYCTepbf9z8HNohEkNuRlWc9dxjA75033iFPsFrNMCsn/lixD1J9Ez9NOXTAqiWFmd/nl7 t8mDsI8qhlE40xnDa2bZ6p6Znoyc+/m55yNjUoE/+8DvS5iXY8mS7aGHKvQTZgyp/Ye1YuKmw17+u lGa4fMJ4Xk7nvpZpwW9YsyA1YYybwcbNSYcU42BCe3MLvUAn63+JrZVz683mflCIFMA4OCYWcPa7x 2PPpkmyXA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPQFv-0007Vt-07; Mon, 05 Oct 2020 13:10:19 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPQFs-0007V1-5J for linux-arm-kernel@lists.infradead.org; Mon, 05 Oct 2020 13:10:17 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 26696207BC; Mon, 5 Oct 2020 13:10:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601903415; bh=kDjkkbRUbpOP0s/mbwqdmPJKM4HIZwidUfRO/Yv/FQw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=r9K6pmsQVtLYS/JRnrZIBTBmJC0nvLDZNOF/a8V/iMZfyIsrdMcqjHjm7xYIhqEBR 4qVHGlZ9NbjN4LG9aAVVdf9CBXO+xQzPpKbKXG6pqlR33+eit7iR9NVmoyZj79Koh2 m3zuOdF05CvQ/3tsGGolWWL14W6WH+i/KN8kej9Q= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kPQFp-00HNNO-4d; Mon, 05 Oct 2020 14:10:13 +0100 MIME-Version: 1.0 Date: Mon, 05 Oct 2020 14:10:13 +0100 From: Marc Zyngier To: Thierry Reding Subject: Re: [PATCH 3/3] soc/tegra: pmc: Don't create fake interrupt hierarchy levels In-Reply-To: <20201005113335.GT425362@ulmo> References: <20201005111443.1390096-1-maz@kernel.org> <20201005111443.1390096-4-maz@kernel.org> <20201005113335.GT425362@ulmo> User-Agent: Roundcube Webmail/1.4.8 Message-ID: X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: thierry.reding@gmail.com, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, jonathanh@nvidia.com, digetx@gmail.com, skomatineni@nvidia.com, vreddytalla@nvidia.com, tglx@linutronix.de, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201005_091016_339661_3C9BAC1F X-CRM114-Status: GOOD ( 27.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Venkat Reddy Talla , linux-kernel@vger.kernel.org, Jonathan Hunter , Sowjanya Komatineni , linux-tegra@vger.kernel.org, Dmitry Osipenko , kernel-team@android.com, Thomas Gleixner , linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 >> --- >> 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... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel