From patchwork Wed Dec 4 12:45:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13893725 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 84B35E77170 for ; Wed, 4 Dec 2024 12:58:30 +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-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/i6+JOTbpNdjy8jM0ECNbKLI0ZaZTnTtdOTtCai+TVs=; b=ICMCn1FtDIkc7PPlKchlQFaBQG BouWxipSICpYB96zs1uBuqvBg5bE+3vLVw9uU5PEBXF0r+Oj7kcTsLudHQ1/Mn5oa1UnpKLCebQmL 78u4EXYAhNoBH2QeKFODoa5TbiShGrvCB5QQsdm1z7ic+uKP5CDucMqJ/BmoB6tqb14qln59UobGV 3HU5MsKLC4uotb2n9GQGb/+Em7Lv1MbKACY3ltMIprziOasfHkx4rsHCYjKOanPEInN6r0+/t5mdM iEgIyL/zedl3hPFGfxi4iNBRdueMfLEPSLruHyO+W6XauWLH951C0pKv734xvavKDG43lWHqbQIK5 UK/sIXyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tIoxM-0000000Catg-0Fvx; Wed, 04 Dec 2024 12:58:16 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tIolc-0000000CYQs-1sRn; Wed, 04 Dec 2024 12:46:10 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 1F7EEA4151A; Wed, 4 Dec 2024 12:44:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA878C4CEE4; Wed, 4 Dec 2024 12:46:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733316366; bh=qwPg4vWceORrtj1oc93ZKHM01ZRkNO9H4Rht+pty/UI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IbsX5b4sS2duxSnQFRgweC+d/Bee9ibNyDCNoabkrmRvCqNOgOhoQ3ADrPSUOnM5U o+Nr3uW+TvyLMkm9CisvsQggJkZ1IVv0AuEY++SlZh8YAxNEtCV2fyxh0adj5UqEUu 317dZM5JQqEHNwvYjxNxX68nL8dmm6CK89JwY0cjORMOYC5uHDIral646J9slE02WH Q5LuzUp7Q2OAlbljEKOqQsLJv/JiWiaTgmkXpWut9mjJUTGbJhMXpwxbyHlo/P3Kai 8Xu0LlKRXaOW9eqH+W+47IDf5dDkvgc51bIKJsN/IGsAg93OKdvd6t4eCfMFL5a0jL 0i047dADaKKTA== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tIolY-000RHy-Gv; Wed, 04 Dec 2024 12:46:04 +0000 From: Marc Zyngier To: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Cc: Joerg Roedel , Suravee Suthikulpanit , David Woodhouse , Lu Baolu , Thomas Gleixner , Shawn Guo , Sascha Hauer , Fabio Estevam , Huacai Chen , WANG Xuerui , Jiaxun Yang , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Manivannan Sadhasivam , Bjorn Helgaas , Toan Le , Alyssa Rosenzweig Subject: [PATCH 02/11] genirq/msi: Add helper for creating MSI-parent irq domains Date: Wed, 4 Dec 2024 12:45:40 +0000 Message-Id: <20241204124549.607054-3-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241204124549.607054-1-maz@kernel.org> References: <20241204124549.607054-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, joro@8bytes.org, suravee.suthikulpanit@amd.com, dwmw2@infradead.org, baolu.lu@linux.intel.com, tglx@linutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com, chenhuacai@kernel.org, kernel@xen0n.name, jiaxun.yang@flygoat.com, andrew@lunn.ch, gregory.clement@bootlin.com, sebastian.hesselbarth@gmail.com, anup@brainfault.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, lpieralisi@kernel.org, kw@linux.com, manivannan.sadhasivam@linaro.org, bhelgaas@google.com, toan@os.amperecomputing.com, alyssa@rosenzweig.io X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241204_044608_622025_65600FEC X-CRM114-Status: GOOD ( 14.86 ) 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 Creating an irq domain that serves as an MSI parent requires a substantial amount of esoteric boiler-plate code, some of which is often provided twice (such as the bus token). To make things a bit simpler for the unsuspecting MSI tinkerer, provide a helper that does it for them, and serves as documentation of what needs to be provided. Signed-off-by: Marc Zyngier --- include/linux/msi.h | 7 +++++++ kernel/irq/msi.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/include/linux/msi.h b/include/linux/msi.h index b10093c4d00ea..f08d14cf07103 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -594,6 +594,13 @@ struct irq_domain *msi_create_irq_domain(struct fwnode_handle *fwnode, struct msi_domain_info *info, struct irq_domain *parent); +struct irq_domain *msi_create_parent_irq_domain(struct fwnode_handle *fwnode, + const struct msi_parent_ops *msi_parent_ops, + const struct irq_domain_ops *ops, + unsigned long flags, unsigned long size, + void *host_data, + struct irq_domain *parent); + bool msi_create_device_irq_domain(struct device *dev, unsigned int domid, const struct msi_domain_template *template, unsigned int hwsize, void *domain_data, diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index 396a067a8a56b..037d85cf0b21c 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -885,6 +885,46 @@ struct irq_domain *msi_create_irq_domain(struct fwnode_handle *fwnode, return __msi_create_irq_domain(fwnode, info, 0, parent); } +/** + * msi_create_parent_irq_domain - Create an MSI-parent interrupt domain + * @fwnode: Optional fwnode of the interrupt controller + * @msi_parent_ops: MSI parent callbacks and configuration + * @ops: Interrupt domain ballbacks + * @flags: Interrupt domain flags + * @size: Interrupt domain size (0 if arbitrarily large) + * @host_data: Interrupt domain private data + * @parent: Parent irq domain + * + * Return: pointer to the created &struct irq_domain or %NULL on failure + */ +struct irq_domain *msi_create_parent_irq_domain(struct fwnode_handle *fwnode, + const struct msi_parent_ops *msi_parent_ops, + const struct irq_domain_ops *ops, + unsigned long flags, unsigned long size, + void *host_data, + struct irq_domain *parent) +{ + struct irq_domain_info info = { + .fwnode = fwnode, + .size = size, + .hwirq_max = size, + .ops = ops, + .host_data = host_data, + .domain_flags = flags | IRQ_DOMAIN_FLAG_MSI_PARENT, + .parent = parent, + .bus_token = msi_parent_ops->bus_select_token, + }; + struct irq_domain *d; + + d = irq_domain_instantiate(&info); + if (IS_ERR(d)) + return NULL; + + d->msi_parent_ops = msi_parent_ops; + return d; +} +EXPORT_SYMBOL_GPL(msi_create_parent_irq_domain); + /** * msi_parent_init_dev_msi_info - Delegate initialization of device MSI info down * in the domain hierarchy