Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3223892pxk; Mon, 5 Oct 2020 04:35:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyILrOTpSqTuwghFlcz7sm7yfoOmWtgVvaq5BemiyK4UDS86+lRGwPM5BtqKe1UiV5N9AaR X-Received: by 2002:a17:906:39ce:: with SMTP id i14mr1082782eje.170.1601897739178; Mon, 05 Oct 2020 04:35:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601897739; cv=none; d=google.com; s=arc-20160816; b=LsqOlRQwfWDTt35GpsLaWuxWUstPbXVpMjMylO1ynbnm0Iz+/+61Jf9/Gdl2sQq+0d cpiE/GUxAX8w4fOwldeXZrrtmYglqKuUj89JJaRJKrVDyQq37CcvB94fL6MjXyQ5+hpI trw73yQHu9wlfq/g9JFycgYtihMIbwo/FGPyVWauzj+Uzk3Wt0cCkzz1am20WfX/7WAX S4CMMXGK0LqaaWxoZWVJTwMSTTcGMWsBhdyLPGFS5ixbL0ygthTa1nKVdGt/Yghb82KS wn5xZZpLFjxoqmUkykbdSuqnkYeTcYq7IFlgZAj9Xs3zYVfyawQuvzPx3jhtul1PuqCu DAmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=vb+TwOIgac5MoVAF3GUMOQDHMZpS4X5tXF1cJJQ1nCY=; b=ZwmienZtGBTs4XxZtcEta9HYICLOFdYgmCHkYxPifNtykwdLLNOjcixftngxie0haw kxV9GGlRd1MXI66ne82ydJztoraRp0j5UpumSczGxPEWEpkeomXQWVQ9v3jBPX9YiLl0 /bqWiVPNwFrJJ7IihrWQNjcbjVyaXdUvy027mgwZ/6AL6VaNUBlVfKC2F1ConM/GEAmL Z5DxL/OhKEBT+YXEdOmW6yM8viMOGAZPHMxw2X6tJEafjfKlEfxD6V2avB0cZVA0816k q/iiUu8G5JWfD5PWsFHFMfbTS0+/wXBNRTGUEIktDku7n7cD38Kfzi79KxALFn1jjD51 dasA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NlzCH3xt; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h27si8035258ejd.325.2020.10.05.04.35.16; Mon, 05 Oct 2020 04:35:39 -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=@gmail.com header.s=20161025 header.b=NlzCH3xt; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725954AbgJELdk (ORCPT + 99 others); Mon, 5 Oct 2020 07:33:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725932AbgJELdj (ORCPT ); Mon, 5 Oct 2020 07:33:39 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66D7FC0613CE; Mon, 5 Oct 2020 04:33:39 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id c8so8912847edv.5; Mon, 05 Oct 2020 04:33:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=vb+TwOIgac5MoVAF3GUMOQDHMZpS4X5tXF1cJJQ1nCY=; b=NlzCH3xtoWaf6qZygPGXybA7Frl4WxD8hLDjKfIg4Lyu/rjNlsCA7fgYmHsmooUEsC 9ABypkalhbvsLnS2I8peWMH4pVuiuJawiJWxlZvV5B8eGUIXzTJRRVBF/Y06ceNloMkE iICYR8oWsqERrZSE0EogTct18xuavv5gtqbHv42IgdWHy/RviLK8uTdXRYIKSJuC3QlA kxjm5w+jVJ/f1A3n2bmCL4MroEq5IQX/zZ35zEmmcnjNcjS4Wka7AsGMACKl7bib96Ln ruelEN/2wIqtJej1kXAlsPo5W9+FfJorIayr4dmAb2l+80sEa1FrGnBKzoUUcCVixzTU wU2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=vb+TwOIgac5MoVAF3GUMOQDHMZpS4X5tXF1cJJQ1nCY=; b=fLynHETNZSRpS9mF24yYUu79URkdInpvqetdIk/l2PQzMHSTHYbZkT0YVVhYHpelwX q6pgsBZuVEPXALWgtXZZ7EkJKrfMyn6CMSqdbP67iVSdgZUYin10QxGqRd88x+6DiKva hTkLGqd5jEHUmmQCpKlMm+RazKO47+oNiolYU5Kg9qALlpPgR55uwps9s2YghiO7+M6Z 74D1tLs2/jjCCTp0h2JmEO5bFDszlQQ2dkhYwmDRJp2KK50+nxBdA+jhR+2Ruv1XZQW6 p47veGoudZNnmx5zEysFxLbe0114FFDFfvu/7j10vDFKyu7cuMKDerWmLwlRyxq8W0EA iEEg== X-Gm-Message-State: AOAM5317hby5Cj+NHSr9LMv4/YzpHz5coX3WBahxyj9Y9kLcwDL/QL4N EJPOlZeCLQGk5X/hPq6KUMY551rX0G0= X-Received: by 2002:a05:6402:a42:: with SMTP id bt2mr16171053edb.193.1601897617963; Mon, 05 Oct 2020 04:33:37 -0700 (PDT) Received: from localhost ([217.111.27.204]) by smtp.gmail.com with ESMTPSA id v25sm8426608edr.29.2020.10.05.04.33.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Oct 2020 04:33:36 -0700 (PDT) Date: Mon, 5 Oct 2020 13:33:35 +0200 From: Thierry Reding To: Marc Zyngier 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 Message-ID: <20201005113335.GT425362@ulmo> References: <20201005111443.1390096-1-maz@kernel.org> <20201005111443.1390096-4-maz@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="D5tFrmRBv7YOLFOK" Content-Disposition: inline In-Reply-To: <20201005111443.1390096-4-maz@kernel.org> User-Agent: Mutt/1.14.7 (2020-08-29) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --D5tFrmRBv7YOLFOK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. >=20 > 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... >=20 > 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. >=20 > Signed-off-by: Marc Zyngier > --- > drivers/soc/tegra/pmc.c | 79 +++++++++++++++-------------------------- > 1 file changed, 29 insertions(+), 50 deletions(-) >=20 > 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_doma= in *domain, > return 0; > } > =20 > +/* 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 =3D 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 !=3D doma= in) > + irq_data =3D irq_data->parent_data; > + > + /* Sever the inner part of the hierarchy... */ > + tail =3D irq_data->parent_data; > + irq_data->parent_data =3D NULL; > + > + /* ... and free it */ > + for (irq_data =3D tail; irq_data; irq_data =3D tail) { > + tail =3D 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. I volunteer to do that work if you think it's a good idea. Thierry --D5tFrmRBv7YOLFOK Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAl97BI8ACgkQ3SOs138+ s6EuNhAApCC/Y3UxL04Yc45mEeylUQ9lbVX8t5YJdJfEEoWIl9a4nCmfszoDz6Jr 0EO3/atnQLyx3E5Lm61/yKshCOrvO6AQNTx//P++eEhIiRcz/HPQQ2dZ5RKCYP/g /cRW8F6S92TdE1hlVuvhEi3cTR2fpdBbo5+y6sNvaHppg9U3mZEXttMB7vb9Ftv9 xFzCk9vIKXfrD5trhyhqgpN8P4rIcq68XWUkJYonv34qO8FmTHziUC6NtJgKesuN RLdDOtyLHVQrJ0h+kU492Gqki5kX7hJRlqxu0EI9tYWWIqYFZT6hylJ4Ozn5v53h zeMLezl3AF6PxQinW0Pg7wWcyJtWb3QSBD+HGW/6jXtzQOtdwqZSCRwJ7ylA+Axz fb5lFkxvT5LcWSZEFk75yCns759w79jSqDgnYUSZJTiG/0FoamgAG5iMXTsTdwJn DDuqiWVpIslq3AvO0IyYNSwwmzSmQBsQkr84mnvFEcPMhrrN/u46AeqAHJRsXUQ+ uZoiUmKL5Hbrpg3GQz6DRAB4nW1wollWyhF1PTiHkImmIhacYijzsb3Y32QJKRom wysRz/m0L9OcXt9lH1KTGjDQbvZa+yAFG2QpPkFuGqstcyI8FJkiH9y3bQd0eJeS YgSfnwxv2zC9kjD92FdFg6iofeY9OJglDyG0oPYr4zVwEhty7SM= =GsHC -----END PGP SIGNATURE----- --D5tFrmRBv7YOLFOK--