Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp539516rwd; Wed, 31 May 2023 01:47:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7E02tivjvvGR+Cbi6fXEYDYX8146AZvrqRF9KXtdRywk4Hu2R9FD+qD775ZTSTewekyjnb X-Received: by 2002:a05:6a20:1447:b0:10a:e9ff:808d with SMTP id a7-20020a056a20144700b0010ae9ff808dmr6106139pzi.0.1685522877117; Wed, 31 May 2023 01:47:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685522877; cv=none; d=google.com; s=arc-20160816; b=L5LNofu41vlzGmLg1Kp2GPxh5C7My6IUlfAu/Gmu0qpi0rWx6XOYvG+dme70N3ku3j 8+WPZo73WlvEWg1Iuzse9NDT3Qh0E9GGju1cJ3mcNsDN3K282BRMFsQRnKi2Wc242i/S gp3yi9t8yG87Xjswb+5GOxXUm25fG9f5qSmMeeNOcOu0hVGydK5SiVyZg4NlSW6O7Jwd j0tRkHVaWDaTmgnBlOpJDUkSRtK2g1rRwPqeCw6JkkcGm9oerl4/l0aDoAZuTNSiZhLA m8S8Woh1QGaUIfuSRkBE2OjeLCIVVo7dWGDrT1llZtXcO/8wksdbPxkB3Rq83OqM+KpU 0Xzg== 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=lHswiE/XX9xYbEj8NrD2o9P5FM3lQtNViCf+/iijOiw=; b=uA30/ayFHMSKTbLKuWJxntgdGtTikLhr7KspARe2bHwfcQd46Dk/5SwEKGmU/Vp4Fb 6bkVbhRaoSNLximSKlAO6bEg7/0EuOoSYm+pyfcqXMbn+TwAxTcm5IZ1kgybLvfuTJNJ qm6ZBxC1DwAMB0vFrmQNtBwSnzeKP9b+/C3TD0MYvW4cErT/Trxalz5Qf4SMOBjuO/DN r6I3juF9FcQuqQ6j0wuRX+fraMso/eC0kU3am1my5JM21K66r3IaO6XdS6I2tpBqW/Jb PhT9KBp0TZG0vkBXmt0C7P0YBRwKJjovwFCslQZFURmXul2uMpba5mRRG86eCVgKPqB7 zd0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=N5TFcW7Q; 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 x22-20020a656ab6000000b0053f23442f29si616211pgu.528.2023.05.31.01.47.45; Wed, 31 May 2023 01:47:57 -0700 (PDT) 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=N5TFcW7Q; 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 S234430AbjEaIfP (ORCPT + 99 others); Wed, 31 May 2023 04:35:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235112AbjEaIfL (ORCPT ); Wed, 31 May 2023 04:35:11 -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 A8E61122; Wed, 31 May 2023 01:35:07 -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 3556862871; Wed, 31 May 2023 08:35:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E457C433EF; Wed, 31 May 2023 08:35:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685522106; bh=NvnORJxFYk7Gbi9d+lRiKRLianbRU171EPYVxebojBQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=N5TFcW7QfAm4i7Jr8Eu5N6ipqg9wVM7yUZYxuGQqkY2ughfXFASU8XWJ607C2vmtK DKZR3sj3VLJAUrwCizJPjNLU9rNDtWbhDE2ZT2cFKGu8yd+80HEgusu3FPFpJjMpqG QHcWMBFhM5KEKbtiVkZYchimZvjfNNIS66Y/BNe2U1yY/XzzY8uHNMLyG8+Kwf6pUR 7ADPZGhTGh953nl+J0EzPGjqQW6fg6fN5QwR4EePiqtr3wPMz9easemvNKYNi5g6NR v4yfjo6KdAcxbsRl/B+MbsxtACM7m4HtB/S07V4JNhJN9RXTL5N8tG0XrTpqHnZsbM kS4PDHWOxrkYQ== 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 1q4HIO-001YmU-AJ; Wed, 31 May 2023 09:35:04 +0100 Date: Wed, 31 May 2023 09:35:03 +0100 Message-ID: <861qiwdhl4.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: <87lehfurij.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> <86r0r7cpks.wl-maz@kernel.org> <87lehfurij.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 X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 Tue, 23 May 2023 14:05:56 +0100, Thomas Gleixner wrote: > > On Tue, May 23 2023 at 11:25, Marc Zyngier wrote: > > On Mon, 22 May 2023 15:19:39 +0100, > > Thomas Gleixner wrote: > >> 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. > > Sure. There are 3 parts involved: > > [Device]--->[PCI/MSI]---->[GIC] > irqchip irqchip > > Controlling the interrupt machinery in the device happens at the device > driver level and is conceptually independent of the interrupt > manangement code. The device driver has no access to the PCI/MSI irqchip > and all it can do is to enable/disable the source of the interrupt in > the device. > > For the interrupt management code the job is to ensure that an interrupt > can be prevented from disrupting the OS operation independent of the > device driver correctness. > > As a matter of fact we know that PCI/MSI masking ranges from not > possible over flaky to properly working. So we can't reliably prevent > that a rougue device spams the PCIe bus with messages. > > Which means that we should utilize the fact that the next interrupt chip > in the hierarchy can mask reliably. I wish I could disable individual > vectors at the local APIC level on x86... > > Now the question is whether we want to make this conditional depending > on what the PCI/MSI[X] hardware advertises or just keep it simple and do > it unconditionally. I think this should be unconditional if the root irqchip (the GIC in this instance) is capable of it. So a suggestion where the root irqchip exposes its masking capability, which upon detection by the upper layer (whateverbusyouwant/MSI) makes it stop playing with its own device-level mask has my full support (and now breathe normally). Thanks, M. -- Without deviation from the norm, progress is not possible.