From patchwork Mon Nov 21 14:39:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 13051224 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 AE670C4332F for ; Mon, 21 Nov 2022 14:55:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=eJHRBiAKJ7YB/jEv1Aa6r+Jf2lWWng3yc4fDAorSinA=; b=0gvtjScYIz7umo 9kkMQWdkDjazaDiwztSR+vcrpvF+2Rjf9nZcjVIvZz5GnzUsjJVnk1Kmj6Du/4B7xP+ICxGRz9kZZ /T7Cnkl8SX6yATS9pIjWmDHYkviPWucbYimgNfCQ/kpG1tO9wqE6Zw7KTndPLdK+3X4zCDRBTZ76k F+Svd6b/64YUnJiRxN7b+R8ru8HFEH43Uus7SgZHbk7hm9v4TAAj6PU13008N0o8PFEGnlVaMPmV1 0vLOuMJVdAN92epnZqdgm99qWnFtRgJTL5mcJDgarV52zStPXuMpMwOo8MgOEyNlGtKaqCoxqFBTv qRBQc3PFgzIIZVpPuObw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ox8Ba-00EtHe-3k; Mon, 21 Nov 2022 14:54:14 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ox7xk-00Eie5-BV for linux-arm-kernel@lists.infradead.org; Mon, 21 Nov 2022 14:39:58 +0000 Message-ID: <20221121140049.617825672@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041595; 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: references:references; bh=JA4DJhkL/SLZbiCPUtuJ/m0vEuiHsTx0BFOI4LdR10Q=; b=ydxHf/DSO9NqBzlSdDCOGZV8yc29f1kRL496Hy5wKB99tucPeKGC07lk3cKpyK9+2COl8c hjpk4rku7hZme1xQb60Ze8od18AYw/U/L2FQTdDLhNWxF1q2REtqR5/VICsDuxiJDB+qC0 lePu9FthiNaXK0Rayd8iIfrfZy6hntLOUUWK3SvBG0wHXaB3rlJfUg+mmaV1yVMogOQ0qO iyNdELpqvPfrCQ2G9j99NQ/+0mbIKlUkx7U34Vo67IglWB5tvwZKq+IEfLuluvvIjHQSQs ovcOyuCpqFarEwyiIVojI+sCJBBvrZpvQMmJdRhtj7dFDiaAwRJeSDubKzD7Wg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041595; 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: references:references; bh=JA4DJhkL/SLZbiCPUtuJ/m0vEuiHsTx0BFOI4LdR10Q=; b=tpDw1REhwrgyCWZKJtswkMSb0d8Ir1QxPnOwIaV2QLUMOPSg/Ophl8ZWx4MgtiwRW5aUTF J3CTK4CKHP0XrJCw== From: Thomas Gleixner To: LKML Cc: Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , 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 Subject: [patch V2 21/40] genirq/msi: Optionally use dev->fwnode for device domain References: <20221121135653.208611233@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:39:54 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221121_063956_624452_470D5933 X-CRM114-Status: GOOD ( 17.24 ) 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 To support wire to MSI domains via the MSI infrastructure it is required to use the firmware node of the device which implements this for creating the MSI domain. Otherwise the existing firmware match mechanisms to find the correct irqdomain for a wired interrupt which is connected to a wire to MSI bridge would fail. This cannot be used for the general case because not all devices provide firmware nodes and all regular per device MSI domains are directly associated to the device and have not be searched for. Signed-off-by: Thomas Gleixner --- include/linux/msi.h | 2 ++ kernel/irq/msi.c | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -536,6 +536,8 @@ enum { * handled in the core MSI code. */ MSI_FLAG_NOMASK_QUIRK = (1 << 7), + /* Use dev->fwnode for MSI device domain creation */ + MSI_FLAG_USE_DEV_FWNODE = (1 << 8), /* Mask for the generic functionality */ MSI_GENERIC_FLAGS_MASK = GENMASK(15, 0), --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -998,9 +998,9 @@ bool msi_create_device_irq_domain(struct void *chip_data) { struct irq_domain *domain, *parent = dev->msi.domain; - const struct msi_parent_ops *pops; + struct fwnode_handle *fwnode, *fwnalloced = NULL; struct msi_domain_template *bundle; - struct fwnode_handle *fwnode; + const struct msi_parent_ops *pops; if (!irq_domain_is_msi_parent(parent)) return false; @@ -1023,7 +1023,19 @@ bool msi_create_device_irq_domain(struct pops->prefix ? : "", bundle->chip.name, dev_name(dev)); bundle->chip.name = bundle->name; - fwnode = irq_domain_alloc_named_fwnode(bundle->name); + /* + * Using the device firmware node is required for wire to MSI + * device domains so that the existing firmware results in a domain + * match. + * All other device domains like PCI/MSI use the named firmware + * node as they are not guaranteed to have a fwnode. They are never + * looked up and always handled in the context of the device. + */ + if (bundle->info.flags & MSI_FLAG_USE_DEV_FWNODE) + fwnode = dev->fwnode; + else + fwnode = fwnalloced = irq_domain_alloc_named_fwnode(bundle->name); + if (!fwnode) goto free_bundle; @@ -1050,7 +1062,7 @@ bool msi_create_device_irq_domain(struct fail: msi_unlock_descs(dev); free_fwnode: - kfree(fwnode); + kfree(fwnalloced); free_bundle: kfree(bundle); return false;