Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3288098pxk; Mon, 5 Oct 2020 06:12:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsy7csd3s5QUbj4RGTkP1YPqJSDAT9Y11RMgDvnER3boVn/hLPPMCC/I4LMkBAhVWXfY4u X-Received: by 2002:a17:906:c191:: with SMTP id g17mr16118759ejz.117.1601903576947; Mon, 05 Oct 2020 06:12:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601903576; cv=none; d=google.com; s=arc-20160816; b=i/iTv6c0JlxzxcnBsJcJSgK9Zal0mOuW0TyTWh4ebUrqob4/WN7VDRtFX2IVAyfGJo jQkZky+qez+fyzDXdoT3EY6qQltBQg/7wxyHGVvVa7uRac7S20Op+taCknm6LXDUwM3u VIGRtPhfKjfExsntZ+eeMOvy8vUw+Jz87n5vD1jVydCTMcrMzEhHqLdeX26ROdexMpqj Ue4i2OpWuoUz5twD677vsVHt2zuQULEYAjJ8aMMlj6HSKJRPySNWPBEGSLetlzyj0Clb NbaHeBDtLRxMwauhpQULz4nzHtme/Cf5mHPlOp5vtrUus9jhnkP1dm88nXTivpV/Js1z bRAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=S/lsRUMbvDVYXJeGOGqfPKNzOAegWlI+HjfjxuBYa00=; b=VDQVc4p8w3v2SySBbw/2xY9RDXnQJI5cm6/sgzUCMKLFnisl9y/U6oTIhxE2ekfjEf YIMVygV+LnN0Ld4RU5FJfRbBU0pEVlzgMArkIkzltDvruEUT0IyeVDZAlf3qHjFF5tL6 SVLaG7XnKZUf/0BRDvDhgqCbSXAx+Jx9d/IFTEida9gTImOV98NH/FQ8dj5m4/wv75mN yeVWbg+NCmH+NhkLwFwt8UWDod0AR6kja8y+4OZfx47cxQtzBGo6VUCCvCkv1/Nm6IKB XXXxt+4bk6CMaErgLhguENax0PwGBfQq0rJxFNcAN01otxxf63V/Jqf3zeGVWhsgNn0D UYDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=r9K6pmsQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si7353448ejt.659.2020.10.05.06.12.33; Mon, 05 Oct 2020 06:12:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=r9K6pmsQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725982AbgJENKQ (ORCPT + 99 others); Mon, 5 Oct 2020 09:10:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:33146 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725891AbgJENKQ (ORCPT ); Mon, 5 Oct 2020 09:10:16 -0400 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 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 05 Oct 2020 14:10:13 +0100 From: Marc Zyngier To: Thierry Reding Cc: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Jonathan Hunter , Dmitry Osipenko , Sowjanya Komatineni , Venkat Reddy Talla , Thomas Gleixner , kernel-team@android.com 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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...