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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20FFEC77B75 for ; Tue, 23 May 2023 10:25:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230041AbjEWKZX (ORCPT ); Tue, 23 May 2023 06:25:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229758AbjEWKZV (ORCPT ); Tue, 23 May 2023 06:25:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 875AC94; Tue, 23 May 2023 03:25:20 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 1A540629E5; Tue, 23 May 2023 10:25:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10711C433D2; Tue, 23 May 2023 10:25:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684837519; bh=bVF4P4TLoqF9NzA727Ndl4mHf4vkDIs82DyqWk2MbEE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ay7HNQ48D1jj5/UNscaWnaoknIegl7HkPbMigAnuMpNk/VoehH1ipcBmahPqVPf+b mRBwNUGVtJw7Mw/5187+EbuAqz2Us3xbOUaHWDFKj6P/oRCO2BCbn6kLCaOazl6h1p qrEk+OVd5nH3VZvZH6JFSlm6xmDYCs9lwQSbkwVWDM86iTOvndLYWEIu2mwkELLLwU s5DtChSzDHQUmUu/oqdMPe4sXYHVwYiQbxh48Yl88FMiHZ0E8+usDUM2OHAhXj3qPg siRbs38Z51sLhsvwyozCvye0awrgsjSIKvFt164t0WuRURK1q8bd2j0lVyVU2HN1J4 XRsGRJbpwsp3w== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1q1PCe-00HKM9-Cd; Tue, 23 May 2023 11:25:16 +0100 Date: Tue, 23 May 2023 11:25:07 +0100 Message-ID: <86r0r7cpks.wl-maz@kernel.org> From: Marc Zyngier To: Thomas Gleixner Cc: LKML , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Greg Kroah-Hartman , Jason Gunthorpe , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Ammar Faizi , Robin Murphy , Lorenzo Pieralisi , Nishanth Menon , Tero Kristo , Santosh Shilimkar , linux-arm-kernel@lists.infradead.org, Vinod Koul , Sinan Kaya , Andy Gross , Bjorn Andersson , Mark Rutland , Shameerali Kolothum Thodi , Zenghui Yu , Shawn Guo , Sascha Hauer , Fabio Estevam , Anna-Maria Behnsen Subject: Re: [patch V2 06/40] PCI/MSI: Provide static key for parent mask/unmask In-Reply-To: <87ttw4wiro.ffs@tglx> References: <20221121135653.208611233@linutronix.de> <20221121140048.659849460@linutronix.de> <8635a8o65q.wl-maz@kernel.org> <87bkowcx0z.ffs@tglx> <86zgcgmpzl.wl-maz@kernel.org> <87v8n3c2qy.ffs@tglx> <87ttw4wiro.ffs@tglx> 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/28.2 (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: tglx@linutronix.de, linux-kernel@vger.kernel.org, will@kernel.org, linux-pci@vger.kernel.org, bhelgaas@google.com, lorenzo.pieralisi@arm.com, gregkh@linuxfoundation.org, jgg@mellanox.com, andrew@lunn.ch, gregory.clement@bootlin.com, sebastian.hesselbarth@gmail.com, ammarfaizi2@gnuweeb.org, robin.murphy@arm.com, lpieralisi@kernel.org, nm@ti.com, kristo@kernel.org, ssantosh@kernel.org, linux-arm-kernel@lists.infradead.org, vkoul@kernel.org, okaya@kernel.org, agross@kernel.org, andersson@kernel.org, mark.rutland@arm.com, shameerali.kolothum.thodi@huawei.com, yuzenghui@huawei.com, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com, anna-maria.behnsen@linutronix.de 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-pci@vger.kernel.org On Mon, 22 May 2023 15:19:39 +0100, Thomas Gleixner wrote: > > On Fri, Nov 25 2022 at 01:11, Thomas Gleixner wrote: > > On Thu, Nov 24 2022 at 13:38, Marc Zyngier wrote: > >> On Thu, 24 Nov 2022 13:17:00 +0000, > >> Thomas Gleixner wrote: > >>> > I find this a bit odd. If anything, I'd rather drop the masking at the > >>> > PCI level and keep it local to the interrupt controller, because this > >>> > is likely to be more universal than the equivalent PCI operation > >>> > (think multi-MSI, for example, which cannot masks individual MSIs). > >>> > > >>> > Another thing is that the static key is a global state. Nothing says > >>> > that masking one way or the other is a universal thing, specially when > >>> > you have multiple interrupt controllers dealing with MSIs in different > >>> > ways. For example, GICv3 can use both the ITS and the GICv3-MBI frame > >>> > at the same time for different PCI RC. OK, they happen to deal with > >>> > MSIs in the same way, but you hopefully get my point. > >>> > >>> I'm fine with dropping that. I did this because basically all of the > >>> various ARM PCI/MSI domain implementation have a copy of the same > >>> functions. Some of them have pointlessly the wrong order because copy & > >>> pasta is so wonderful.... > >>> > >>> So the alternative solution is to provide _ONE_ set of correct callbacks > >>> and let the domain initialization code override the irq chip callbacks > >>> of the default PCI/MSI template. > >> > >> If the various irqchips can tell the core code whether they want > >> things to be masked at the PCI level or at the irqchip level, this > >> would be a move in the right direction. For the GIC, I'd definitely > >> want things masked locally. > >> > >> What I'd like to get rid off is the double masking, as I agree it is > >> on the "pretty dumb" side of things. > > > > Not necessarily. It mitigates the problem of MSI interrupts which can't > > be masked because the implementers decided to spare the gates. MSI > > allows that as masking is opt-in... > > > > Let me think about it. > > That really took a while to think about it :) > > We have the following cases on the PCI/MSI side: > > 1) The MSI[X] entry can be masked > > 2) The MSI[X] entry cannot be masked because hardware did not implement > it, masking is globally disabled due to XEN, masking does not exist > for this horrible virtual MSI hackery And as a bonus the case of non-PCI MSIs, which are definitely a thing, and I'd like them to fit in the same model (because life is too short to do anything else). As for the Xen side, I hope to never have to care about it for the architecture I care about (I've long proclaimed Xen/arm64 dead and buried). > > Now you said: > > "For the GIC, I'd definitely want things masked locally." > > I decoded this, that you want to have these interrupts masked at the GIC > level too independent of #1 or #2 above. And then: > > "What I'd like to get rid off is the double masking." > > But relying on the GIC alone is not really a good thing IMO. There is no > point to let some confused device send unwanted MSI messages around > without a way to shut it up from the generic code via the regular > mask/unmask callbacks. I have a slightly different view of the problem. The device masking is somehow orthogonal with the masking at the GIC level: - can the interrupt be generated: this is a device property - can the interrupt be signalled: this is an interrupt controller property In a way, this is no different from your basic device, such as a timer: you need both the interrupt generation to be enabled at the timer level, and the interrupt signalling to be enabled (unmasked) at the irqchip level. Today, we conflate the two, because we have either: - devices that cannot selectively mask interrupts - interrupt controllers that are limited in what they can mask and this results in the terrible pattern that's all over the GIC-related stuff. > On the other hand for PCI/MSI[x] the mask/unmask operations are not in > the hot path as PCI/MSI[x] are strictly edge. Mask/unmask is only > happening on startup, shutdown and when an interrupt arrives after > disable_irq() incremented the lazy disable counter. > > For regular interrupt handling mask/unmask is not involved. > > So to avoid that global key we can let the parent domain set a new flag, > e.g. MSI_FLAG_PCI_MSI_MASK_PARENT, in msi_parent_ops::supported_flags > and let the PCI/MSI core code query that information when the per device > domain is created and select the appropriate template or fixup the > callbacks after the domain is created. > > Does that address your concerns? It does to a certain extent. But what I'd really like is that in the most common case where the interrupt controller is capable of masking MSIs, the PCI/MSI *enabling* becomes the responsibility of the PCI core code and not the IRQ code. The IRQ code should ideally only be concerned with the masking of the interrupt at the irqchip level, and not beyond that. And that'd solve the Xen problem by merely ignoring it. If we have HW out there that cannot mask MSIs at the interrupt controller level, then we'd have to fallback to device-side masking, which doesn't really work in general (MultiMSI being my favourite example). My gut feeling is that this is rare, but I'm pretty sure it exists. Thanks, M. -- Without deviation from the norm, progress is not possible.