From nobody Fri Dec 19 19:01:33 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 23AFB32F76F; Tue, 21 Oct 2025 12:41:15 +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=1761050477; cv=none; b=iOuxxbbmG7y3M6td1cf54ei95YULRpjVY3NA4Hdo+Bz68j+bVNvVadlynuMvNEG/dylLv8Ha54ajz9cjh6Q39HVHbsGBEXThn20gIogoWyuBOXi+ozLcgbwSBv+b0GXpC3hYdm2XE7ln+VSms/g/x4HdP8pCq/wsEgv2LI11cOA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761050477; c=relaxed/simple; bh=r/G+FZpStTM0vbk0p20owxrN91C3+v6SvIg6ZwkVinQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XW2iHLf7cCGQ3H45eCjsKQ7VyP8ugScpwCuxo9LR53F1dIjGMOaY4Z53FiqELQwEoecR4EeaehBpsjguh+QYcfQ/VjBaeTOfCCehtY1MN4earSihHSxEzLHgLKquecG0XzYDMV3MAja3fZbScNPR5Xs4kauYEx+QL2/LwToTtuk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=t41wDtyC; 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="t41wDtyC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F63DC4CEF1; Tue, 21 Oct 2025 12:41:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761050475; bh=r/G+FZpStTM0vbk0p20owxrN91C3+v6SvIg6ZwkVinQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t41wDtyCzusMv2f+XoJcJNP2U1VOcNslC7ZTMSGIYkeb6Vl21CxUDNgiibrqabq/l Mc/GWVrBmnGLkZ5dMromcl0cQqI+KCJmRW64VL1pplho/ol8QclamFtQcA5wQcyT4c vPS74W86Izx13lDO4yX+6zTHbTaVFtoQ8KG5Y/Vgd7d5Y8GX8R3MgYEMNZyVetUhTP 4pp+xS5o9KXvAJmwntx+ba48Nzobun9OHjtwvomac5wL5e/iUzhLDI7pgleO8EnIYu wk/tbxYn6GGKobMswLSa+EZVe1vAw47vYL4zlD00yZJAWd6PDNxrIUmpA5A43KJK0k iZup1PZMdPLgg== From: Lorenzo Pieralisi To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-pci@vger.kernel.org, Frank Li , Sascha Bischoff , Rob Herring , Marc Zyngier , Scott Branden , Thomas Gleixner , Bjorn Helgaas , Ray Jui , Manivannan Sadhasivam , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= Subject: [PATCH v4 1/5] of/irq: Add msi-parent check to of_msi_xlate() Date: Tue, 21 Oct 2025 14:40:59 +0200 Message-ID: <20251021124103.198419-2-lpieralisi@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251021124103.198419-1-lpieralisi@kernel.org> References: <20251021124103.198419-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 Reviewed-by: Frank Li Cc: Sascha Bischoff Cc: Rob Herring Cc: Marc Zyngier --- drivers/of/irq.c | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 65c3c23255b7..321d40ec229b 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -671,6 +671,36 @@ 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) + return 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 +708,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 +722,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 Fri Dec 19 19:01:33 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 550A9332EA2; Tue, 21 Oct 2025 12:41: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=1761050481; cv=none; b=CS+qqR2Z+98D9Qyi1quKgDa1EYDj8wX6AECoAqkTxQJplnK9TBYGtZ7L9My0lanmRxVnq73wD2lLVeXVQv6kNAYgYqV9jfMqgES0f4oViz6c/gYcpK1FoSm8Dau97JhuNZoZ5bDm8j2/QlMo5PjD+6g8muuG2OG+nJdWWKIp4bM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761050481; c=relaxed/simple; bh=+KrQ8+/Xpeyyg0XnnZnoOXc5K2eE7Yf3Idw+8Qii2j8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D38Owdr3YyiHUHYcYXnLr6avV6yPPbc+uEk4C1B7ENuXd29+ZMa/E53SPwqNTiq5JUZSmbp1hrbBjeJUOjUrhAVgcxty6fsldQq7lFhyxYQKMyVAv2mTjI3WGaURo7baD8uaoJcA0BRhi4UQKG+f07WscXR9DjN6h9xHXMfWs64= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P8kbiDNk; 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="P8kbiDNk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60AFDC4CEFF; Tue, 21 Oct 2025 12:41:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761050480; bh=+KrQ8+/Xpeyyg0XnnZnoOXc5K2eE7Yf3Idw+8Qii2j8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P8kbiDNknMZb/FC+i5v5f+TFVKK+HM/KGJTHGUFkJwM3orpLLSq+vpuZhATlyhVPp Kzc2YTzXJJqczzz1z9sLQdClMg1HeLI1mcmXTT6/lLPPkhLOhZm6eioJqrQv36oJy6 PLE0gC19x+g6UoJN3oVY9RmI/FloI06eWdJsWKsG6CVKUXSVr7MjMFwYL05YAueJ3X YyNHG8v0vQVbYX+vPi+pLgbwhVbNizAj8q777TlUPkv5F4OHm9MpAhSTtUACM6Uujg 3TThY0i2tXtfxI+Q8Sc6p5PryAXgUZAUf1r69b/aPRIO7o7/fJJbvNa0oGp93dsgzI jd29mY0IyC2ig== From: Lorenzo Pieralisi To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-pci@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 v4 2/5] of/irq: Fix OF node refcount in of_msi_get_domain() Date: Tue, 21 Oct 2025 14:41:00 +0200 Message-ID: <20251021124103.198419-3-lpieralisi@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251021124103.198419-1-lpieralisi@kernel.org> References: <20251021124103.198419-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 321d40ec229b..ee7d5f0842e8 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -774,8 +774,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 Fri Dec 19 19:01:33 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 03205333427; Tue, 21 Oct 2025 12:41:25 +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=1761050486; cv=none; b=FdKPo4/HDQ4PY2ZpP8lvmDQF2afTjy6X9xSFqtJ3sHTWP/0KEtGcPfTW/XswfcZ7JfUg5u8lpleFwRPtDtDyfu9zrev+Kw2ubpVGv4G1tjqp42bi0u0TGL9ExAE8dXdUCqu216kXbgFYTr1XL99N0ZgOhIoNSkBoU7g+mSz8D+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761050486; c=relaxed/simple; bh=ZdCUUMchR3IZHrUpOETZdGuUsxzbyMb4ecC2yoA5/tY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qKiSj3VXnxqt7UNWu82CM5xVp7OKg3tqbiJxl03Zz80wbaiE/eS8bQUagp4M54lK1BSOzIHOqFDg+Mhy9MrC93eUAdrjRGabs9hAGnwep9wwo72kdiHJdw7A76ci1852V8KIdIf6hG/pudpbrk0Xpn4ThhwTm1UMpboO6j8UT3o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vEm0zSa0; 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="vEm0zSa0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E432C4CEF1; Tue, 21 Oct 2025 12:41:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761050485; bh=ZdCUUMchR3IZHrUpOETZdGuUsxzbyMb4ecC2yoA5/tY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vEm0zSa0zJ6EnD5StWuKbGLFC0eDn3fHQFlf+4FSbpIc3KBJcWeNm73cMpaaEAeXn itPOwyLtd+G0Hq+qMxmqgbtN65fSldGQxAktR0BI6Ohaeb4+1K8trUVYPApig3HGZr S06gptoO3CVkhIDPrNUeLHu877VE1DXIEZUI6KAbNRT0zGlNglCfiYjCyQMZYTlL0m moEJ72WdLXOkCib/2IiRgFpkoqJ0GPPGokkp2RWmKqpAjvGklHU5Og1FbyK+SqSFb5 bgtoqBx9nFkNwXTzVDW/r6Mspx8Ro3mm8hr3W6j43W3lCqHhUAwDhUerFklH6ckKBs aIsEl2zXnKLqg== From: Lorenzo Pieralisi To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-pci@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 v4 3/5] of/irq: Export of_msi_xlate() for module usage Date: Tue, 21 Oct 2025 14:41:01 +0200 Message-ID: <20251021124103.198419-4-lpieralisi@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251021124103.198419-1-lpieralisi@kernel.org> References: <20251021124103.198419-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 Reviewed-by: Frank Li Cc: Rob Herring Acked-by: Rob Herring (Arm) --- drivers/of/irq.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/of/irq.c b/drivers/of/irq.c index ee7d5f0842e8..1cd93549d093 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -733,6 +733,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 Fri Dec 19 19:01:33 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 75BF732E754; Tue, 21 Oct 2025 12:41:31 +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=1761050491; cv=none; b=P07/OvWt/0Y1393HFO2AgV2AbU1XnzqrTNfgquhYZWaClVVP6Zq+6ilWY61eOlqv6HescQldKnqHWnP8n/+B4/U/aarrnibJJXO8DsfMflX7LSEOATzaY/HaIU0IOeVeDGwZKozomzNheLV2uyCY9VtTWi9No8It/aAyJTQNGqg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761050491; c=relaxed/simple; bh=NG4e6thsmTs+tS4vAqcXpl8k/SUzrCPff2en/NEAlIs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZiiMVznbqCRxp/smSNaDAQuaPPzs/0Yb3ZuTVLtelfW1/9oO9/Wn1uTeEQBRk4GnQsgPARFEAmK9LmuxNWbKc5FM6/qvvNN9IkEx561rL2+fA/0bVhX8IJc4ZdT47Scjtp/QOf3G9pNzPmryfmcyMSqyrUVXPTcEJlBv5sWIVT4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PyV4Vj00; 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="PyV4Vj00" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82D95C4CEF5; Tue, 21 Oct 2025 12:41:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761050491; bh=NG4e6thsmTs+tS4vAqcXpl8k/SUzrCPff2en/NEAlIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PyV4Vj00JSE9dHMgq5+mweq44ZXS3oBAvJenwdHZoR3yAKZ6m8mppRde7nDnEgkWn jsPriWl0ODqyceq5hu8CzNajIC37GJuGGivY9xoyMrzfL+0VG9AyJb9hw+1+2OYhUh OcnjxMIPJ3VLVR9TYdwKiJXzJ9EzXCwYCdSw53oRsxXJfMM/Wyh07GD3LIIHwLiBL3 W3dEila7lPO9kfyrIk2v12ypt+G9ZGSBexV+xfaBSc4tUyzG/XhW8aReXQciKGaYAP mm4rB772/7kNbPdFa4xQZc+GwD7OlWX3Qs212aUiLdyNNO1BYJBusoIDHHNuwpzum8 B5KQNjcR8uXaw== From: Lorenzo Pieralisi To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-pci@vger.kernel.org, Frank Li , Scott Branden , Bjorn Helgaas , Rob Herring , Ray Jui , Manivannan Sadhasivam , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Sascha Bischoff , Thomas Gleixner , Marc Zyngier Subject: [PATCH v4 4/5] PCI: iproc: Implement MSI controller node detection with of_msi_xlate() Date: Tue, 21 Oct 2025 14:41:02 +0200 Message-ID: <20251021124103.198419-5-lpieralisi@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251021124103.198419-1-lpieralisi@kernel.org> References: <20251021124103.198419-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 Reviewed-by: Frank Li Cc: Scott Branden Cc: Bjorn Helgaas Cc: Rob Herring Cc: Ray Jui Cc: Manivannan Sadhasivam Cc: "Krzysztof Wilczy=C5=84ski" Acked-by: Bjorn Helgaas --- 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 Fri Dec 19 19:01:33 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 29E2A32E758; Tue, 21 Oct 2025 12:41:35 +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=1761050496; cv=none; b=QuLbbyCljQSi//5UrXiJDXyHv5AIr0zNw6fv9VjUeMwhImVoPnRjgMNEK1wJpGGmVc4AzmqyfnGCQH5PKuFtsh2hThtt9Wdht6rUmbUbcwVk8bKIC4dJvXxigv9m5z6mnmgDrfx8/lOHsXHRvpvnFLKbI+4kIhpxJsHjWaYVs3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761050496; c=relaxed/simple; bh=lIxv+EOrd7W/T3yQOT8mtVWXOvtvQNfZtoBJMGvuAgQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K60Fc0+pUNvIgsgso0C+/ikg7wD/33Z4gik2x76IUaaj25G3VcosIbY2ocFqBEA8AwyH1sFb/D4R1NbTQJn8a6ZJ43Xo+ELfV5H9C0GnVsmLqmd8N20Q5rDVcNZg82iXbjQNzRs54HnRjhVFRhQBch0YoBFRR6rHUwoUg2JcsNA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Y5V+PM1S; 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="Y5V+PM1S" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0221C4CEF5; Tue, 21 Oct 2025 12:41:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761050495; bh=lIxv+EOrd7W/T3yQOT8mtVWXOvtvQNfZtoBJMGvuAgQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y5V+PM1S7j1UNUR81QDzTZlPRWg6zF0y3K/cdtYfRcaHss2RLBb+uSqvg6YCY6hny fSqHBX6pQYwD1caY5HNwdqnXjcLhAq1Hi/fp3I3ozw25eBtvTXCIc6wec5Ib7rkU3J 2UgxvnPmRJroYF5PJKOfqW0b1RWhseXexRlad7kmKflSG6UZPh8w0SnxRjL7I19bDC a0N1VLWDiwhwA4pm/2EWCDJcEdyfavfW5HzAs2cyiufinqJIO5DF7q5rwM1E9+bN6O gFR8RIglS4TTXmH+CkOH9hxegrSN+0iV2GNFV7U4Swd8ceMB7Ol6SHa5oGyhmroenR bE0IONoPOX+0Q== From: Lorenzo Pieralisi To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-pci@vger.kernel.org, Frank Li , Sascha Bischoff , Thomas Gleixner , Rob Herring , Marc Zyngier , Scott Branden , Bjorn Helgaas , Ray Jui , Manivannan Sadhasivam , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= Subject: [PATCH v4 5/5] irqchip/gic-its: Rework platform MSI deviceID detection Date: Tue, 21 Oct 2025 14:41:03 +0200 Message-ID: <20251021124103.198419-6-lpieralisi@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251021124103.198419-1-lpieralisi@kernel.org> References: <20251021124103.198419-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 Reviewed-by: Frank Li Cc: Sascha Bischoff Cc: Thomas Gleixner Cc: Rob Herring Cc: Frank Li Cc: Marc Zyngier Reviewed-by: Marc Zyngier --- 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