Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp414215pxp; Sat, 5 Mar 2022 07:14:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxEi3KQaQgankAuSkCmWi6BP1x+zbP9pGI0p7uVcp1DT2ktkjrHTVfF4MK1QTCyblSJwJVz X-Received: by 2002:a05:6214:2684:b0:435:17c2:70fe with SMTP id gm4-20020a056214268400b0043517c270femr3004914qvb.78.1646493262292; Sat, 05 Mar 2022 07:14:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646493262; cv=none; d=google.com; s=arc-20160816; b=oZ7zzBc340T/i9J5uqNPXEwK/HI+JHUYdFrUNLmkmu6epht/I80lCzvsJe6IlK0BoY 5W1XovNbZ6Jbmrjr0QjP32GbGfxTb1yvm0hl2nUgNBsHi1mg5hv+s319z6Hu2aMy7z5K PYRERyhY1FFYXIrHoUv6wgbdJdljjGO7QkbUaCY2yjhw2j15i/EPvy9zAdPwjfF18L0O +HtiQVUebVtsJoS2zg1L4YTujx1Wvjf6WDZ9yQ7QtZNc1Q8wOKomwtXIvExUbtEKBCTF oGbHHkeoPEflM1b5sLuCLgesbK30Wz4oxWwpazSiHpqrzP7wU3np25ySFfprbSfFkFKL pZuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=OuXXuaRi5T4qYclFwxEOx7SzHJSqTvzUr0FJlTO3YBs=; b=Cj6HBg7zksnEUjq3BYKVkP4Pn4fE2wP02Noi5ry7VdgDar2TlUjEWzgWQr4K31hANs b05+gaRGNioLmIgmIjr+YFLKepzhHrLBBmj8vNXArdIfp5z1WVdjGKb34POMdbgwxdsb x4+ByC6ORK+vAsJoEUOqCzM8nb+xpYnqqPacBhpXeLV/38A/LhPA8pN6RIiua6SvWUv7 UmJ/FfqqCYXtLZyXmnV63/ieqHTF/al+WgpV1BPp98lFr57SCuP42wv1GSAn+l8nfNy+ Gh8VgQ+rhVCk+8sQgfXvhHUwLNEBkYvcFm6D8zzIiEDD2TtnvY6Ap/Ivmjpk5B3CaU+/ htKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IzI1XW1n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g1-20020a05620a218100b006635c666893si2137597qka.674.2022.03.05.07.14.06; Sat, 05 Mar 2022 07:14:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IzI1XW1n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231551AbiCELGF (ORCPT + 99 others); Sat, 5 Mar 2022 06:06:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbiCELGD (ORCPT ); Sat, 5 Mar 2022 06:06:03 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E6EF49275; Sat, 5 Mar 2022 03:05:13 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 03C9CB801BF; Sat, 5 Mar 2022 11:05:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9219FC004E1; Sat, 5 Mar 2022 11:05:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646478310; bh=sBvaL1nYVqIYei+YFhToiSOr8DcSm1Ymz6XxVlrvysU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=IzI1XW1nWd1FlLj+5ahQEJeDY1PS4U3KGLMOVZZX+dqb5ZGssBvwepN3LgXNaaNlP j0lVqs2iQ492fK1Clz4gVdeoG6d8U0synyRtUZWL2lcY8+cYbQ8AAVI7hC9uxoP6Wa ADTARA2hsi4XfJJ6wDD0+jHiZaOU8L9cjAQhU3LI4rXqjevHS3Gf3XeR6l6V0cllys AnBgVd5EEWX91/AtvC+EOFMwfehvxgSpe5vQMhPxcZUn7/frLSLwgWfyEOeg2gVAdB Zpa1aCupxVkejGvzC0IZwbS0oy3pdU1gf8lxwbd+PBMC6LpT+H0I5nyBPef4zKAQJm HGXcjkll9bwiw== Received: from sofa.misterjones.org ([185.219.108.64] helo=billy-the-mountain.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nQSDk-00CQQC-0v; Sat, 05 Mar 2022 11:05:08 +0000 Date: Sat, 05 Mar 2022 11:05:07 +0000 Message-ID: <87czj0u0bg.wl-maz@kernel.org> From: Marc Zyngier To: Shawn Guo Cc: Thomas Gleixner , Maulik Shah , Bjorn Andersson , Sudeep Holla , Rob Herring , devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v7 2/2] irqchip: Add Qualcomm MPM controller driver In-Reply-To: <20220305092420.GP269879@dragon> References: <20220301062414.2987591-3-shawn.guo@linaro.org> <87ee3m2aed.wl-maz@kernel.org> <20220302084028.GL269879@dragon> <877d9c3b2u.wl-maz@kernel.org> <20220302133441.GM269879@dragon> <875yow31a0.wl-maz@kernel.org> <20220303040229.GN269879@dragon> <87fsnytagc.wl-maz@kernel.org> <20220304082342.GO269879@dragon> <87lexp211g.wl-maz@kernel.org> <20220305092420.GP269879@dragon> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: shawn.guo@linaro.org, tglx@linutronix.de, quic_mkshah@quicinc.com, bjorn.andersson@linaro.org, sudeep.holla@arm.com, robh+dt@kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 05 Mar 2022 09:24:20 +0000, Shawn Guo wrote: > > On Fri, Mar 04, 2022 at 03:24:43PM +0000, Marc Zyngier wrote: > > On Fri, 04 Mar 2022 08:23:42 +0000, > > Shawn Guo wrote: > > > > > > On Fri, Mar 04, 2022 at 07:59:15AM +0000, Marc Zyngier wrote: > > > > On Thu, 03 Mar 2022 04:02:29 +0000, > > > > Shawn Guo wrote: > > > > > > > > > > On Wed, Mar 02, 2022 at 01:57:27PM +0000, Marc Zyngier wrote: > > > > > > This code actually makes me ask more questions. Why is it programming > > > > > > 2 'pins' for each IRQ? > > > > > > > > > > The mapping between MPM pin and GIC IRQ is not strictly 1-1. There are > > > > > some rare case that up to 2 MPM pins map to a single GIC IRQ, for > > > > > example the last two in QC2290 'qcom,mpm-pin-map' below. > > > > > > > > > > qcom,mpm-pin-map = <2 275>, /* tsens0_tsens_upper_lower_int */ > > > > > <5 296>, /* lpass_irq_out_sdc */ > > > > > <12 422>, /* b3_lfps_rxterm_irq */ > > > > > <24 79>, /* bi_px_lpi_1_aoss_mx */ > > > > > <86 183>, /* mpm_wake,spmi_m */ > > > > > <90 260>, /* eud_p0_dpse_int_mx */ > > > > > <91 260>; /* eud_p0_dmse_int_mx */ > > > > > > > > > > > > > > > The downstream uses a DT bindings that specifies GIC hwirq number in > > > > > client device nodes. In that case, d->hwirq in the driver is GIC IRQ > > > > > number, and the driver will need to query mapping table, find out the > > > > > possible 2 MPM pins, and set them up. > > > > > > > > > > The patches I'm posting here use a different bindings that specifies MPM > > > > > pin instead in client device nodes. Thus the driver can simply get the > > > > > MPM pin from d->hwirq, so that the whole look-up procedure can be saved. > > > > > > > > It still remains that there is no 1:1 mapping between input and > > > > output, which is the rule #1 to be able to use a hierarchical setup. > > > > > > For direction of MPM pin -> GIC interrupt, it's a 1:1 mapping, i.e. for > > > given MPM pin, there is only one GIC interrupt. And that's the > > > mapping MPM driver relies on. For GIC interrupt -> MPM pin, it's not > > > a strict 1:1 mapping. > > > > Then this isn't a 1:1 mapping *AT ALL*. The hierarchical setup > > mandates that the mapping is a bijective function, and that's exactly > > what 1:1 means. There is no such thing a 1:1 in a single > > direction. When you take an interrupt, all you see is the GIC > > interrupt. How do you know which of the *two* pins interrupted you? Oh > > wait, you *can't* know. You end-up never servicing one of the two > > interrupts > > Yes, you are right! But that might be a problem only in theory. I > checked all the Qualcomm platforms I know built on MPM, and found that > the only 2:1 case is USB DP & DM sensing pins. Since these two pins > will be handled by USB driver with a single interrupt handler, it should > not cause any problem in practice. That said, the 2:1 mapping is just > a special case specific to USB, and MPM driver can be implemented as if > it's just a 1:1 mapping. > > Shawn > > > (and I suspect this results in memory corruption if you > > tear a hierarchy down). Key point here ^^^^^^^^^^ You can't have *any* interrupt that fits this 2:1 model if the irqchip implements 1:1. Think about the data structures for a second: Pins x and y and routed to GIC interrupt z. This results in the following irq_data structures: MPM-x ---\ GIC-z MPM-y ---/ Now, the driver using these interrupts is being removed, and the hierarchies is being freed. Tearing down the interrupt with pin x will result in z being also freed. And then you'll process pin y, which will just explode. So either you make sure these mappings can never be created, or you change the driver to not be hierarchical. You absolutely cannot have it both ways. M. -- Without deviation from the norm, progress is not possible.