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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A32EC27C6E for ; Fri, 14 Jun 2024 16:10:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=PZOkXNrjYzzOPT0yriiDUdIBuXYhX5z42aV0C0OMWp4=; b=kcClETc1NgZ8p4 pW9ux9EwcxVeZMmj5f6yOwwBMRAtb420x+8tB7J2w+V9qwrYZOLr5f3lGCuC7xaPQrqTyk5+jLRRz 68qTMWA84g+twxIy7cS2XVqD/cLyf2UMl/nix08v/z7B5nTYrygoiyvb8HqS7mF/C8Cd7w1pOdiYB mLDRMqW4ebi49U2+sKfgBnaCgGUTW+jKc3KLnMl5kiz6/a433t6CRFuvKZSWEiu9QOPIc2CNMTE9R Ol8MI8ekiTet4ONUxNjLRisquR6h58ARSmI15BPgBV1seyl2dDYyOonVA3gNua7f6aXJ+FMrE+/PT ODwMdFKSowJnUAMFkKIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sI9Us-00000003Ldz-3c9v; Fri, 14 Jun 2024 16:09:50 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sI9Up-00000003Lch-1pYm for linux-arm-kernel@lists.infradead.org; Fri, 14 Jun 2024 16:09:49 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id C9880CE2B84; Fri, 14 Jun 2024 16:09:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD8B3C2BD10; Fri, 14 Jun 2024 16:09:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718381384; bh=i6G4moCMnqhzFyyBB6tQeSxoa8cndGODhPD7vUB4a4Y=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=GCAnvxS16+wFmkgOlsKpHUFr0GxQY+1IH7051TFHP+y8chtyCdRQ6URBbZTj4GRMp TiLUDs+dq0ihSVDDozhG6Q43TtwjOVIZ0kvyDrns5Wh4wO2NXOriUpKZw8WueFBQaG 4m6/3bKGGhWuh51mQxiq/q+y6LazAKFyJC2hLpBMaWTZ/72yB2gMjGG0Jwr12wXzke Hvw/h18FfHXppTfW4KkX+OWwzY9JaD/mpbjZQutYJt+sd3OVFuS7QnLwlQ3g+bsA+M vghRkD9ubmqFr7wc1Onm7x6r+NpUCEIzRMXo55H2YceUqHnuNWuo4scooIiAdCfyfY xuTd8/yy6slYw== Date: Fri, 14 Jun 2024 11:09:42 -0500 From: Bjorn Helgaas To: Shivamurthy Shastri Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, maz@kernel.org, tglx@linutronix.de, anna-maria@linutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com, bhelgaas@google.com, rdunlap@infradead.org, vidyas@nvidia.com, ilpo.jarvinen@linux.intel.com, apatel@ventanamicro.com, kevin.tian@intel.com, nipun.gupta@amd.com, den@valinux.co.jp, andrew@lunn.ch, gregory.clement@bootlin.com, sebastian.hesselbarth@gmail.com, gregkh@linuxfoundation.org, rafael@kernel.org, alex.williamson@redhat.com, will@kernel.org, lorenzo.pieralisi@arm.com, jgg@mellanox.com, ammarfaizi2@gnuweeb.org, robin.murphy@arm.com, lpieralisi@kernel.org, nm@ti.com, kristo@kernel.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 Subject: Re: [PATCH v3 03/24] PCI/MSI: Provide MSI_FLAG_PCI_MSI_MASK_PARENT Message-ID: <20240614160942.GA1114672@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240614102403.13610-4-shivamurthy.shastri@linutronix.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240614_090947_865308_8FBD1BFA X-CRM114-Status: GOOD ( 24.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jun 14, 2024 at 12:23:42PM +0200, Shivamurthy Shastri wrote: > Most ARM(64) PCI/MSI domains mask and unmask in the parent domain after or > before the PCI mask/unmask operation takes place. So there are more than a > dozen of the same wrapper implementation all over the place. Is this an opportunity to clean up all these wrappers? If you could mention an example or two here, maybe somebody would be motivated to come back and simplify the existing wrappers to take advantage of this new flag? > Don't make the same mistake with the new per device PCI/MSI domains and > provide a new MSI feature flag, which lets the domain implementation > enable this sequence in the PCI/MSI code. > > Signed-off-by: Shivamurthy Shastri I assume you'll merge this series via some other tree, so: Acked-by: Bjorn Helgaas > --- > v3: new patch to replace the global static key - Marc Zyngier > --- > drivers/pci/msi/irqdomain.c | 21 +++++++++++++++++++++ > include/linux/msi.h | 2 ++ > 2 files changed, 23 insertions(+) > > diff --git a/drivers/pci/msi/irqdomain.c b/drivers/pci/msi/irqdomain.c > index 03d2dd25790d..112c2ff3035c 100644 > --- a/drivers/pci/msi/irqdomain.c > +++ b/drivers/pci/msi/irqdomain.c > @@ -148,17 +148,35 @@ static void pci_device_domain_set_desc(msi_alloc_info_t *arg, struct msi_desc *d > arg->hwirq = desc->msi_index; > } > > +static __always_inline void cond_mask_parent(struct irq_data *data) > +{ > + struct msi_domain_info *info = data->domain->host_data; > + > + if (unlikely(info->flags & MSI_FLAG_PCI_MSI_MASK_PARENT)) > + irq_chip_mask_parent(data); > +} > + > +static __always_inline void cond_unmask_parent(struct irq_data *data) > +{ > + struct msi_domain_info *info = data->domain->host_data; > + > + if (unlikely(info->flags & MSI_FLAG_PCI_MSI_MASK_PARENT)) > + irq_chip_unmask_parent(data); > +} > + > static void pci_irq_mask_msi(struct irq_data *data) > { > struct msi_desc *desc = irq_data_get_msi_desc(data); > > pci_msi_mask(desc, BIT(data->irq - desc->irq)); > + cond_mask_parent(data); > } > > static void pci_irq_unmask_msi(struct irq_data *data) > { > struct msi_desc *desc = irq_data_get_msi_desc(data); > > + cond_unmask_parent(data); > pci_msi_unmask(desc, BIT(data->irq - desc->irq)); > } > > @@ -170,6 +188,7 @@ static void pci_irq_unmask_msi(struct irq_data *data) > > #define MSI_COMMON_FLAGS (MSI_FLAG_FREE_MSI_DESCS | \ > MSI_FLAG_ACTIVATE_EARLY | \ > + MSI_FLAG_PCI_MSI_MASK_PARENT | \ > MSI_FLAG_DEV_SYSFS | \ > MSI_REACTIVATE) > > @@ -195,10 +214,12 @@ static const struct msi_domain_template pci_msi_template = { > static void pci_irq_mask_msix(struct irq_data *data) > { > pci_msix_mask(irq_data_get_msi_desc(data)); > + cond_mask_parent(data); > } > > static void pci_irq_unmask_msix(struct irq_data *data) > { > + cond_unmask_parent(data); > pci_msix_unmask(irq_data_get_msi_desc(data)); > } > > diff --git a/include/linux/msi.h b/include/linux/msi.h > index dc27cf3903d5..04f33e7f6f8b 100644 > --- a/include/linux/msi.h > +++ b/include/linux/msi.h > @@ -556,6 +556,8 @@ enum { > MSI_FLAG_USE_DEV_FWNODE = (1 << 7), > /* Set parent->dev into domain->pm_dev on device domain creation */ > MSI_FLAG_PARENT_PM_DEV = (1 << 8), > + /* Support for parent mask/unmask */ > + MSI_FLAG_PCI_MSI_MASK_PARENT = (1 << 9), > > /* Mask for the generic functionality */ > MSI_GENERIC_FLAGS_MASK = GENMASK(15, 0), > -- > 2.34.1 >