From nobody Sat Feb 7 12:19:23 2026 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 D1D3229D279; Fri, 17 Oct 2025 08:48:03 +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=1760690883; cv=none; b=mkKx0F3sCRmH0h/5woBAK2juHlB+VnltvUmG59AGELmk7/2Jezn0jxj0nsXF7hxu0vcDRc0aWVD1ONqMN3am1gWSl27gukka3YuSwk3Vb3oAkD/h2tsJjC3nMFk8O8VkEXBas0q1Y2PABqo/nlKdpoDfbai1CUaQZqmhhVVIX5I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760690883; c=relaxed/simple; bh=JVj1gYQNdufw+TmwhieihG8R1MzSzSkm4Nvrx/BeRBs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=diWC8sIuFakwexcnkhGLg1KVclKeoulN+dhMrfVO9yS8flHeafv9SLgBHg/+vWZcrayAVQ+Aqc+/8uTmxCubYNCJVq5LyCuPa5+xs13wtdXJG3C/iEMk6DlGSTeoH2cduRHGPrWdq2NWw17cGxt5n9Tqyuwa9bHabSJFT/jH8zQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TMlgi6WD; 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="TMlgi6WD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA19FC4CEFE; Fri, 17 Oct 2025 08:47:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760690883; bh=JVj1gYQNdufw+TmwhieihG8R1MzSzSkm4Nvrx/BeRBs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TMlgi6WDROJvwgsEFXAEcTDSDrW8nYAs4gVgJxVxXbtbjlkFM/L8DmJAWzsAjVtN+ nLwVrG7goFBuZUXW2wQMXuWZdOAFuieKugLtiYHB7AedkkEkL/VfP4b0y/pwmD3vaa 7F75z/Gn5tkrYQrSf6+g+35Zws9wdtlu4RJ2tMFwtWtPsBepu6Vs6srtZJezRkSDZT Yl0z1C/PdSi5UzcPrxW3sfA6PpZe4jzK61K/GZqrRqMEy0QpL/kFhEbNXqnntYoa/4 uz80e2fjmefO/YeiaORkjcPNw/4B99PfHTDPxyiyJ40Fadcs84UTcuxsPaxnSFop5k QIe490Cvp8uRw== From: Lorenzo Pieralisi To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, Sascha Bischoff , Rob Herring , Marc Zyngier , Scott Branden , Thomas Gleixner , Bjorn Helgaas , Ray Jui , Frank Li , Manivannan Sadhasivam , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= Subject: [PATCH v3 1/5] of/irq: Add msi-parent check to of_msi_xlate() Date: Fri, 17 Oct 2025 10:47:48 +0200 Message-ID: <20251017084752.1590264-2-lpieralisi@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251017084752.1590264-1-lpieralisi@kernel.org> References: <20251017084752.1590264-1-lpieralisi@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 Content-Type: text/plain; charset="utf-8" In some legacy platforms the MSI controller for a PCI host bridge is identified by an msi-parent property whose phandle points at an MSI controller node with no #msi-cells property, that implicitly means #msi-cells =3D=3D 0. For such platforms, mapping a device ID and retrieving the MSI controller node becomes simply a matter of checking whether in the device hierarchy there is an msi-parent property pointing at an MSI controller node with such characteristics. Add a helper function to of_msi_xlate() to check the msi-parent property in addition to msi-map and retrieve the MSI controller node (with a 1:1 ID deviceID-IN<->deviceID-OUT mapping) to provide support for deviceID mapping and MSI controller node retrieval for such platforms. Fixes: 57d72196dfc8 ("irqchip/gic-v5: Add GICv5 ITS support") Signed-off-by: Lorenzo Pieralisi Cc: Sascha Bischoff Cc: Rob Herring Cc: Marc Zyngier Reviewed-by: Frank Li --- drivers/of/irq.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 65c3c23255b7..e67b2041e73b 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -671,6 +671,35 @@ void __init of_irq_init(const struct of_device_id *mat= ches) } } =20 +static int of_check_msi_parent(struct device_node *dev_node, struct device= _node **msi_node) +{ + struct of_phandle_args msi_spec; + int ret; + + /* + * An msi-parent phandle with a missing or =3D=3D 0 #msi-cells + * property identifies a 1:1 ID translation mapping. + * + * Set the msi controller node if the firmware matches this + * condition. + */ + ret =3D of_parse_phandle_with_optional_args(dev_node, "msi-parent", "#msi= -cells", + 0, &msi_spec); + if (!ret) { + if ((*msi_node && *msi_node !=3D msi_spec.np) || msi_spec.args_count != =3D 0) + ret =3D -EINVAL; + + if (!ret) { + /* Return with a node reference held */ + *msi_node =3D msi_spec.np; + return 0; + } + of_node_put(msi_spec.np); + } + + return ret; +} + /** * of_msi_xlate - map a MSI ID and find relevant MSI controller node * @dev: device for which the mapping is to be done. @@ -678,7 +707,7 @@ void __init of_irq_init(const struct of_device_id *matc= hes) * @id_in: Device ID. * * Walk up the device hierarchy looking for devices with a "msi-map" - * property. If found, apply the mapping to @id_in. + * or "msi-parent" property. If found, apply the mapping to @id_in. * If @msi_np points to a non-NULL device node pointer, only entries targe= ting * that node will be matched; if it points to a NULL value, it will receiv= e the * device node of the first matching target phandle, with a reference held. @@ -692,12 +721,15 @@ u32 of_msi_xlate(struct device *dev, struct device_no= de **msi_np, u32 id_in) =20 /* * Walk up the device parent links looking for one with a - * "msi-map" property. + * "msi-map" or an "msi-parent" property. */ - for (parent_dev =3D dev; parent_dev; parent_dev =3D parent_dev->parent) + for (parent_dev =3D dev; parent_dev; parent_dev =3D parent_dev->parent) { if (!of_map_id(parent_dev->of_node, id_in, "msi-map", "msi-map-mask", msi_np, &id_out)) break; + if (!of_check_msi_parent(parent_dev->of_node, msi_np)) + break; + } return id_out; } =20 --=20 2.50.1 From nobody Sat Feb 7 12:19:23 2026 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 34A6E23BF91; Fri, 17 Oct 2025 08:48: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=1760690892; cv=none; b=Q+7BMQRtZVMrJcCzZJrKr865jyAo1Jef8Ilve74dOulSD0NArUGfywYXKntZUuyM9LPA/FNiaGu5DBAZEOOLN5E3yhFtYv0z3xrvqUdcMYgcHGV/W3+2QUGi7hlpcu/wGiwnUXLTIw9KAvS/ESavLZlu69tmAqCJmXV3iryMyhI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760690892; c=relaxed/simple; bh=XGXorEJawrWEzTdrR4D/nXvovbfYzhFoHVqFZYAEOXc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cb+EIUg1/tl5W6FNTc8zn6CSIZsmDcQ8y60GsXFwYOIROiGKvlFiXE9bATj68FdUnYvNk5COsxuNo85yNZg94YU5nZObz4W05Fpr5xUKcht6X1XkvbnKRFA5bVo5wxCQnJUmRjzsnRPFQqV56aEtyGyVY4Px42flS2KC72MMvdY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=m5QYaH/W; 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="m5QYaH/W" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8D40C113D0; Fri, 17 Oct 2025 08:48:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760690887; bh=XGXorEJawrWEzTdrR4D/nXvovbfYzhFoHVqFZYAEOXc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m5QYaH/WEXygWVrPOjMqdEhRrPdFXruUYtqnHZ4Fmv8H3ZWEzwwid0w3JeLYbrv6k 8aWbPMNETE4+njNuSsGmJ06/LoOwD0Nf2sVekIfotn4vCR9sSAqEb0ogSuIIW0bneu QdzoH+VyKUf+qiqScez0+3XbbPtYvx0qkWF1s/tAqdBtH7Ox7M13htnmRPMOy6dWU0 LwE4sGc7oVOD3yWiXmM4wBDEITiKazUQnJotUasF7MYeUbPp4Dv0EVjQ21pemjj+Yb h5v8nvNYoSqzh9RMxijXBZB0v/mI4ZZQ6zyZ/wX/8vaphS4RZOS+hPO0P12uaO3MKe A6Pg1Sedj6y1g== From: Lorenzo Pieralisi To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, Frank Li , Rob Herring , Sascha Bischoff , Scott Branden , Thomas Gleixner , Bjorn Helgaas , Ray Jui , Manivannan Sadhasivam , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Marc Zyngier Subject: [PATCH v3 2/5] of/irq: Fix OF node refcount in of_msi_get_domain() Date: Fri, 17 Oct 2025 10:47:49 +0200 Message-ID: <20251017084752.1590264-3-lpieralisi@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251017084752.1590264-1-lpieralisi@kernel.org> References: <20251017084752.1590264-1-lpieralisi@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 Content-Type: text/plain; charset="utf-8" In of_msi_get_domain() if the iterator loop stops early because an irq_domain match is detected, an of_node_put() on the iterator node is needed to keep the OF node refcount in sync. Add it. Signed-off-by: Lorenzo Pieralisi Reviewed-by: Frank Li Cc: Rob Herring --- drivers/of/irq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/of/irq.c b/drivers/of/irq.c index e67b2041e73b..9f6cd5abba76 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -773,8 +773,10 @@ struct irq_domain *of_msi_get_domain(struct device *de= v, =20 of_for_each_phandle(&it, err, np, "msi-parent", "#msi-cells", 0) { d =3D irq_find_matching_host(it.node, token); - if (d) + if (d) { + of_node_put(it.node); return d; + } } =20 return NULL; --=20 2.50.1 From nobody Sat Feb 7 12:19:23 2026 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 2CFA723958C; Fri, 17 Oct 2025 08:48:12 +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=1760690892; cv=none; b=fVqPf4VoHMK8cHuVRfgW5A+/DqYigNYEoaT18Ik4ZoWeukr8l0/iKo4+UG6Lo8s5lh51O3rtPNkEgwlWv7aVRbAkm6XIMzU0+nqXbapsSKkkMl4R18jsJrR90WEMVWtxRVMDlVEM5jDAHUQwrAlGSXv9xxSRLNdDtdeYtP9gufc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760690892; c=relaxed/simple; bh=aQM8S1gRQ5jL8Y273uYJ9Sl4vppeQ81J+AkspAyr2H8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UGvAoj/y19qY/f7DW4LitZlNU9veGnZeCJlYASV31nSOqd5lt0mlyybaKzCJDzJKCouzrOc5PrAeq3JgmoT722PnbuMjL47d1Ku2B4jSe2zKaiQAX3xul2GftLJ9KmC69UF/N9wI//Id1nOErHnGQc2FGz72GGuPD0mihdFuPY4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OsutJEW5; 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="OsutJEW5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CC0BC116C6; Fri, 17 Oct 2025 08:48:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760690892; bh=aQM8S1gRQ5jL8Y273uYJ9Sl4vppeQ81J+AkspAyr2H8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OsutJEW55HQyO+td7OWiczhMBPckM32yQP4VtNVV2xrDdYjzrloB/Un+AZ5bIsqbu 01EyN6iYYyuZb50D3HWUCKDjMJwyk28rwfWLjiZLVYCQW8VW6fEgJrLgybyMdpxegH gDVf0LT5hdZzInU/YseP+w1c5cUXrv8QIEqYojzsnjoY2aqiiRKQYwwxkhrqOatb0Z 6UwgnjF4+n0zTwZpB2HwpeosTG60RWUVpOSpwqXOHRIUwPVUr7aJVGE4t7U6kj54QM PwFfnQ4dNFvYF2EukQWYGoFSuLvD1qV4WT4gFXdbvLfvKMopVPQmDScDq3ysb5b2c2 hPRFL57qy+Crw== From: Lorenzo Pieralisi To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, Rob Herring , Sascha Bischoff , Scott Branden , Thomas Gleixner , Bjorn Helgaas , Ray Jui , Frank Li , Manivannan Sadhasivam , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Marc Zyngier Subject: [PATCH v3 3/5] of/irq: Export of_msi_xlate() for module usage Date: Fri, 17 Oct 2025 10:47:50 +0200 Message-ID: <20251017084752.1590264-4-lpieralisi@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251017084752.1590264-1-lpieralisi@kernel.org> References: <20251017084752.1590264-1-lpieralisi@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 Content-Type: text/plain; charset="utf-8" of_msi_xlate() is required by drivers that can be configured as modular, export the symbol. Signed-off-by: Lorenzo Pieralisi Cc: Rob Herring Reviewed-by: Frank Li --- drivers/of/irq.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 9f6cd5abba76..889d0dfbcb3f 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -732,6 +732,7 @@ u32 of_msi_xlate(struct device *dev, struct device_node= **msi_np, u32 id_in) } return id_out; } +EXPORT_SYMBOL_GPL(of_msi_xlate); =20 /** * of_msi_map_get_device_domain - Use msi-map to find the relevant MSI dom= ain --=20 2.50.1 From nobody Sat Feb 7 12:19:23 2026 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 73E7723958C; Fri, 17 Oct 2025 08:48:16 +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=1760690896; cv=none; b=usbCtHEn9dqqb+boiACbDakvzfXBe8FXyQJQfjKqMmKjJvX5XdGxHfVlPQLMnl9JSnmrz6Z3cl6odVrnVRYaT2hSHyNkzt2ERsJqvi+IJF51MJeOtvnUztZRUuTkS7arRfVX+yC5OF3avB6c3LvJKWahZ5z8XEFFLMWe9TqVlfQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760690896; c=relaxed/simple; bh=web6L5TPZtt08mmDaVYY7W2Sw34M19ouNiW4LSSozIA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=egqiIJ0nKlHZiWD+qJKEqngRWRVa2qla38rfWRV8IIpQzdBAm8tRimnzdfrkcCSkP2vKKUn43MQ+Z8yIdB8yXfKcv86L64VSVfp0ERMAyuKRMpQonYUmcknn8leS7QXqlCzI6zPRx9mSDSsl2Pb9oyT4zhB3o1GwC7/OcdfI7bI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gtOQZkVC; 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="gtOQZkVC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 955CEC19422; Fri, 17 Oct 2025 08:48:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760690896; bh=web6L5TPZtt08mmDaVYY7W2Sw34M19ouNiW4LSSozIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gtOQZkVCkVnVCHdtENUCT0nGeZ0l/MU+FQuzWIav1SV3uxLLVwPqSFTTrz+Jj0wCX VU1hymP0EmTcTF9OYHeLQRPRkYsgPtgbwfZ3nC4djnDHs0cND15KNIOnBeDoIhEzHE LK9hxvF9AhqybfE2xcjQR0HbOWaDYVIxSxrEEeRHBDLNArWEM5WhXDboiY6C6Ryso6 ZQKKEfsP4D0FddZohwDDB1U5AO0fuQ1pJqVqZc6B5PY7K6eZKFbyUBTkO8/f+JfELA BBxT5GyhkD2eTw40KnBJSvrTeEPVGZumrO7KBFjOUwEaJG5rKnk+PUfcRIkCrl3GYE NqDdMHL/26zgQ== From: Lorenzo Pieralisi To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, Scott Branden , Bjorn Helgaas , Rob Herring , Ray Jui , Manivannan Sadhasivam , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Sascha Bischoff , Thomas Gleixner , Frank Li , Marc Zyngier Subject: [PATCH v3 4/5] PCI: iproc: Implement MSI controller node detection with of_msi_xlate() Date: Fri, 17 Oct 2025 10:47:51 +0200 Message-ID: <20251017084752.1590264-5-lpieralisi@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251017084752.1590264-1-lpieralisi@kernel.org> References: <20251017084752.1590264-1-lpieralisi@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The functionality implemented in the iproc driver in order to detect an OF MSI controller node is now fully implemented in of_msi_xlate(). Replace the current msi-map/msi-parent parsing code with of_msi_xlate(). Since of_msi_xlate() is also a deviceID mapping API, pass in a fictitious 0 as deviceID - the driver only requires detecting the OF MSI controller node not the deviceID mapping per-se (of_msi_xlate() return value is ignored for the same reason). Signed-off-by: Lorenzo Pieralisi Cc: Scott Branden Cc: Bjorn Helgaas Cc: Rob Herring Cc: Ray Jui Cc: Manivannan Sadhasivam Cc: "Krzysztof Wilczy=C5=84ski" Reviewed-by: Frank Li --- drivers/pci/controller/pcie-iproc.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/p= cie-iproc.c index 22134e95574b..ccf71993ea35 100644 --- a/drivers/pci/controller/pcie-iproc.c +++ b/drivers/pci/controller/pcie-iproc.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -1337,29 +1338,16 @@ static int iproc_pcie_msi_steer(struct iproc_pcie *= pcie, =20 static int iproc_pcie_msi_enable(struct iproc_pcie *pcie) { - struct device_node *msi_node; + struct device_node *msi_node =3D NULL; int ret; =20 /* * Either the "msi-parent" or the "msi-map" phandle needs to exist * for us to obtain the MSI node. */ - - msi_node =3D of_parse_phandle(pcie->dev->of_node, "msi-parent", 0); - if (!msi_node) { - const __be32 *msi_map =3D NULL; - int len; - u32 phandle; - - msi_map =3D of_get_property(pcie->dev->of_node, "msi-map", &len); - if (!msi_map) - return -ENODEV; - - phandle =3D be32_to_cpup(msi_map + 1); - msi_node =3D of_find_node_by_phandle(phandle); - if (!msi_node) - return -ENODEV; - } + of_msi_xlate(pcie->dev, &msi_node, 0); + if (!msi_node) + return -ENODEV; =20 /* * Certain revisions of the iProc PCIe controller require additional --=20 2.50.1 From nobody Sat Feb 7 12:19:23 2026 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 14DB726F292; Fri, 17 Oct 2025 08:48:20 +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=1760690901; cv=none; b=ZwSLv+7oOJk99a7uR8zJsKVFrknOW4QGs/Vauuo7YGP8GpkGwGC+38VA13cXQ7/hgbegOrmAwtqgL4MAAw4PRopmIzDJpSns9dewcAJ9AVrLDmx9RWY8R2/7UhFFyeZ9ZSu2TTUACvpTC1UFsjOzmhHQ4MpcYsEh0TzMVocxLck= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760690901; c=relaxed/simple; bh=RVkyfa65ji+iVeG5m+BwMXCO2f+xUvygzZyer4ipAO8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MbAsEUAz8rNCrZDxNARqHw3U+f1LrZ+QvsxJ54x4Y0+Nma0vQukcO7Y0fuQhPAAmgtjCtWPV4OTLZ0GLow7kLiA/rKPahB7PgCfY1dtOwPBJK/IHuqh2N7hR0p5nOWJ4Au+C0mFyZi+WvSA4OOygjyi0bzBm47LnnGebpyo7ldA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Iwe0TBnp; 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="Iwe0TBnp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC231C4CEE7; Fri, 17 Oct 2025 08:48:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760690900; bh=RVkyfa65ji+iVeG5m+BwMXCO2f+xUvygzZyer4ipAO8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Iwe0TBnpFzClt9Y20jsB2ePw+lmYNVEtgobf2uCd312bcIBSiTLvmqB/vK58wjCg7 Br8cEfkG6bbncGNfesJ5W91OmPOwRWmFvs04zN7PSjoqrvJsqXTJukcFan1g4IwhEZ jidHTOVTykUEe5TYltVzRTC07oxAsXm7vVk05eo84HxModSdqO8TrNr7gvz6P7u2aO CWEWQcvakcB4jIyvWtlrvBPrlZoCU6xTminoCCqSqphTFH83rFesouhB9DODt1Hfim MYc/Kiq60SPXBrXU49Wte2OqeH9t0bIvd2nCiOJbqo+q1QnpNuopvT2nlhWkgCE0BI BYIJrfhLwtHvQ== From: Lorenzo Pieralisi To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, Sascha Bischoff , Thomas Gleixner , Rob Herring , Frank Li , Marc Zyngier , Scott Branden , Bjorn Helgaas , Ray Jui , Manivannan Sadhasivam , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= Subject: [PATCH v3 5/5] irqchip/gic-its: Rework platform MSI deviceID detection Date: Fri, 17 Oct 2025 10:47:52 +0200 Message-ID: <20251017084752.1590264-6-lpieralisi@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251017084752.1590264-1-lpieralisi@kernel.org> References: <20251017084752.1590264-1-lpieralisi@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 Content-Type: text/plain; charset="utf-8" Current code retrieving platform devices MSI devID in the GIC ITS MSI parent helpers suffers from some minor issues: - It leaks a struct device_node reference - It is duplicated between GICv3 and GICv5 for no good reason - It does not use the OF phandle iterator code that simplifies the msi-parent property parsing Consolidate GIC v3 and v5 deviceID retrieval in a function that addresses the full set of issues in one go by merging GIC v3 and v5 code and converting the msi-parent parsing loop to the more modern OF phandle iterator API, fixing the struct device_node reference leak in the process. Signed-off-by: Lorenzo Pieralisi Cc: Sascha Bischoff Cc: Thomas Gleixner Cc: Rob Herring Cc: Frank Li Cc: Marc Zyngier Reviewed-by: Frank Li --- drivers/irqchip/irq-gic-its-msi-parent.c | 91 ++++++------------------ 1 file changed, 23 insertions(+), 68 deletions(-) diff --git a/drivers/irqchip/irq-gic-its-msi-parent.c b/drivers/irqchip/irq= -gic-its-msi-parent.c index eb1473f1448a..12f45228c867 100644 --- a/drivers/irqchip/irq-gic-its-msi-parent.c +++ b/drivers/irqchip/irq-gic-its-msi-parent.c @@ -142,83 +142,38 @@ static int its_v5_pci_msi_prepare(struct irq_domain *= domain, struct device *dev, #define its_v5_pci_msi_prepare NULL #endif /* !CONFIG_PCI_MSI */ =20 -static int of_pmsi_get_dev_id(struct irq_domain *domain, struct device *de= v, - u32 *dev_id) +static int of_pmsi_get_msi_info(struct irq_domain *domain, struct device *= dev, u32 *dev_id, + phys_addr_t *pa) { - int ret, index =3D 0; + struct of_phandle_iterator it; + int ret; =20 /* Suck the DeviceID out of the msi-parent property */ - do { - struct of_phandle_args args; + of_for_each_phandle(&it, ret, dev->of_node, "msi-parent", "#msi-cells", -= 1) { + /* GICv5 ITS domain matches the MSI controller node parent */ + struct device_node *np __free(device_node) =3D pa ? of_get_parent(it.nod= e) + : of_node_get(it.node); =20 - ret =3D of_parse_phandle_with_args(dev->of_node, - "msi-parent", "#msi-cells", - index, &args); - if (args.np =3D=3D irq_domain_get_of_node(domain)) { - if (WARN_ON(args.args_count !=3D 1)) - return -EINVAL; - *dev_id =3D args.args[0]; - break; - } - index++; - } while (!ret); + if (np =3D=3D irq_domain_get_of_node(domain)) { + u32 args; =20 - if (ret) { - struct device_node *np =3D NULL; + if (WARN_ON(of_phandle_iterator_args(&it, &args, 1) !=3D 1)) + ret =3D -EINVAL; =20 - ret =3D of_map_id(dev->of_node, dev->id, "msi-map", "msi-map-mask", &np,= dev_id); - if (np) - of_node_put(np); - } + if (!ret && pa) + ret =3D its_translate_frame_address(it.node, pa); =20 - return ret; -} + if (!ret) + *dev_id =3D args; =20 -static int of_v5_pmsi_get_msi_info(struct irq_domain *domain, struct devic= e *dev, - u32 *dev_id, phys_addr_t *pa) -{ - int ret, index =3D 0; - /* - * Retrieve the DeviceID and the ITS translate frame node pointer - * out of the msi-parent property. - */ - do { - struct of_phandle_args args; - - ret =3D of_parse_phandle_with_args(dev->of_node, - "msi-parent", "#msi-cells", - index, &args); - if (ret) - break; - /* - * The IRQ domain fwnode is the msi controller parent - * in GICv5 (where the msi controller nodes are the - * ITS translate frames). - */ - if (args.np->parent =3D=3D irq_domain_get_of_node(domain)) { - if (WARN_ON(args.args_count !=3D 1)) - return -EINVAL; - *dev_id =3D args.args[0]; - - ret =3D its_translate_frame_address(args.np, pa); - if (ret) - return -ENODEV; - break; - } - index++; - } while (!ret); - - if (ret) { - struct device_node *np =3D NULL; - - ret =3D of_map_id(dev->of_node, dev->id, "msi-map", "msi-map-mask", &np,= dev_id); - if (np) { - ret =3D its_translate_frame_address(np, pa); - of_node_put(np); + of_node_put(it.node); + return ret; } } =20 - return ret; + struct device_node *msi_ctrl __free(device_node) =3D NULL; + + return of_map_id(dev->of_node, dev->id, "msi-map", "msi-map-mask", &msi_c= trl, dev_id); } =20 int __weak iort_pmsi_get_dev_id(struct device *dev, u32 *dev_id) @@ -234,7 +189,7 @@ static int its_pmsi_prepare(struct irq_domain *domain, = struct device *dev, int ret; =20 if (dev->of_node) - ret =3D of_pmsi_get_dev_id(domain->parent, dev, &dev_id); + ret =3D of_pmsi_get_msi_info(domain->parent, dev, &dev_id, NULL); else ret =3D iort_pmsi_get_dev_id(dev, &dev_id); if (ret) @@ -262,7 +217,7 @@ static int its_v5_pmsi_prepare(struct irq_domain *domai= n, struct device *dev, if (!dev->of_node) return -ENODEV; =20 - ret =3D of_v5_pmsi_get_msi_info(domain->parent, dev, &dev_id, &pa); + ret =3D of_pmsi_get_msi_info(domain->parent, dev, &dev_id, &pa); if (ret) return ret; =20 --=20 2.50.1