From patchwork Wed Jun 26 19:05:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 13713291 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 81EADC27C4F for ; Wed, 26 Jun 2024 19:06:13 +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:Content-Type:MIME-Version: Message-ID:Date:References:In-Reply-To:Subject:Cc:To:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EoN4fj2HCZ+g0Mng6LNWulvp3O8suPrcrYKI0Bnjr5Y=; b=F2CV+mqdh2w5xfPpkzTv5+lW+n ZiXglUoAbiMrgNjHU+1UL92eVKpjpZSIEA8LtwW/nWqEmCQh2EAotvfkeGimRjeSbeaKdq8/+NmzD CYsniucUez89dhWlekW07dsNXbgeidpkR7Jd6ffU/3e8BxY5dMVmgYiLuDq65OSisoc+B9aK8bZF8 5vMFTMPE4zhgCpMwLyfYHycuOd1mCgQfPDk/w5TO0zsfxz7MuoTQEoSPwAImkCP1o4dSfzQ54WlJN r/fs6JZt8p2r1oShCvNpNYi7yehqbikIA0RChgUNmolmp5UPHLICW3o5MGhcMB9n+YhkHYOZNJdEi 6f8njlxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMXxy-000000080N2-0QGg; Wed, 26 Jun 2024 19:06:02 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMXxC-0000000809g-1dnd for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 19:05:26 +0000 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1719428713; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EoN4fj2HCZ+g0Mng6LNWulvp3O8suPrcrYKI0Bnjr5Y=; b=0Wux6xPAFVgp7+gpVoEV8EIVMylNp1e/HDRVtFWKeyZZ1iin6uwo70xKF5Njh/koKi2T06 GcjuP4tDa6nmJkaLKHy07rfKmQYIiLJrhdH4uSz2WH10rXQdq8TiIRX7M7ntjPdDmuwvEx nmfllDzP0INE9phqmqDtzS2Qflq7Rfma6ejDGzM6CtcUQ/uHi4fl768/tG14ELxchFlbeR WSE4b7z4zwcMIB+rDX1PFZIZBNAySXrhpwG+RQ8M0wDieBnZSF7S0h0jo+e4L8w0D+47ws 0zroKJ6A2G4iRbKJgKptNuGtIsWefoZDV1JMoYIFq6ignSFpodBbKSBg0Tn5Pg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1719428713; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EoN4fj2HCZ+g0Mng6LNWulvp3O8suPrcrYKI0Bnjr5Y=; b=bWSUS9H8o0a07mxYPBKc/FjUD9MH5DYeGUJulQv2c3b+enEWz6WaNl6SjMwrResG6vl8Yf NY9Q5wStjlTqSfDQ== To: LKML Cc: linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, maz@kernel.org, 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, shivamurthy.shastri@linutronix.de Subject: [patch V4-1 01/21] PCI/MSI: Provide MSI_FLAG_PCI_MSI_MASK_PARENT In-Reply-To: <20240623142234.778182630@linutronix.de> References: <20240623142137.448898081@linutronix.de> <20240623142234.778182630@linutronix.de> Date: Wed, 26 Jun 2024 21:05:12 +0200 Message-ID: <87ed8j34pj.ffs@tglx> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240626_120514_627862_2F6CCF9B X-CRM114-Status: GOOD ( 11.65 ) 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 From: Shivamurthy Shastri 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. 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 Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas --- v4-1: Remove MSI_FLAG_PCI_MSI_MASK_PARENT from the defaults - Rob v3: new patch to replace the global static key - Marc Zyngier --- drivers/pci/msi/irqdomain.c | 20 ++++++++++++++++++++ include/linux/msi.h | 2 ++ 2 files changed, 22 insertions(+) --- a/drivers/pci/msi/irqdomain.c +++ b/drivers/pci/msi/irqdomain.c @@ -148,17 +148,35 @@ static void pci_device_domain_set_desc(m 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)); } @@ -195,10 +213,12 @@ static const struct msi_domain_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)); } --- 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),