From nobody Fri Dec 19 04:53:00 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B72A1BD4E5; Wed, 4 Dec 2024 12:46:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733316367; cv=none; b=N4QEqGqdxLRx71o5YXTUwRG4h6ihwWu1LTa6e2F1NHT3ODDtHQJ66z1iInD+O+UDFkBTNnYJhGXR4m8PY/DkBpzVoJ2gwqxdxsIaEwaClIIcq8mx3bKPrNJomPDm6SQsfyuU4nep8JW576tVMgrEct+O4h0I3Wgf4cYcekrOmSw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733316367; c=relaxed/simple; bh=qwPg4vWceORrtj1oc93ZKHM01ZRkNO9H4Rht+pty/UI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gslhZVQV5KKhsxIROcmSwC5D9OUDSbJazvLr4uGnXpHPqqJ4MQzIB4ju1/90CKfGsxIvN1j3rSlGm6+jwX7cU3FGMSNyg6ZklimShX/4MjqQtuzWFo2ztiUBhibKf0PsDHvzkbQEejSWdJy+Zi9imsL7bboWioWSec6BBBF2m7Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IbsX5b4s; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IbsX5b4s" 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=20Wilczy=C5=84ski?= , 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 Content-Type: text/plain; charset="utf-8" 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); =20 +struct irq_domain *msi_create_parent_irq_domain(struct fwnode_handle *fwno= de, + 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); } =20 +/** + * 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 *fwno= de, + 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 =3D { + .fwnode =3D fwnode, + .size =3D size, + .hwirq_max =3D size, + .ops =3D ops, + .host_data =3D host_data, + .domain_flags =3D flags | IRQ_DOMAIN_FLAG_MSI_PARENT, + .parent =3D parent, + .bus_token =3D msi_parent_ops->bus_select_token, + }; + struct irq_domain *d; + + d =3D irq_domain_instantiate(&info); + if (IS_ERR(d)) + return NULL; + + d->msi_parent_ops =3D msi_parent_ops; + return d; +} +EXPORT_SYMBOL_GPL(msi_create_parent_irq_domain); + /** * msi_parent_init_dev_msi_info - Delegate initialization of device MSI in= fo down * in the domain hierarchy --=20 2.39.2