[PATCH] PCI: qcom: Restrict PERST# parsing to PCI bridge nodes

Xilin Wu posted 1 patch 1 month ago
drivers/pci/controller/dwc/pcie-qcom.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
[PATCH] PCI: qcom: Restrict PERST# parsing to PCI bridge nodes
Posted by Xilin Wu 1 month ago
Commit 2fd60a2edb83 ("PCI: qcom: Parse PERST# from all PCIe bridge
nodes") extended PERST# parsing below the Root Port, so that downstream
PCIe switch bridge nodes can describe their own PERST# GPIOs.

However, the implementation recurses into every available child node.  A
PCI hierarchy may contain non-bridge child nodes with unrelated
"reset-gpios" properties, such as an Ethernet PHY below an MDIO bus.  If
such a reset GPIO is provided by a PCI endpoint GPIO controller, the
endpoint has not been enumerated while the host bridge is still probing.
Trying to acquire that GPIO then returns -EPROBE_DEFER and the Root Port
probe is deferred indefinitely.

Only recurse into child nodes that are PCI bridge/bus nodes.  Keep parsing
the Root Port passed by qcom_pcie_parse_port(), but filter descendants to
nodes with device_type = "pci" and either a bus-range property or an
explicit PCI bridge class compatible.

Fixes: 2fd60a2edb83 ("PCI: qcom: Parse PERST# from all PCIe bridge nodes")
Signed-off-by: Xilin Wu <sophon@radxa.com>
---
 drivers/pci/controller/dwc/pcie-qcom.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c
index af6bf5cce65b..5e0c31cc32a0 100644
--- a/drivers/pci/controller/dwc/pcie-qcom.c
+++ b/drivers/pci/controller/dwc/pcie-qcom.c
@@ -1693,7 +1693,16 @@ static const struct pci_ecam_ops pci_qcom_ecam_ops = {
 	}
 };
 
-/* Parse PERST# from all nodes in depth first manner starting from @np */
+static bool qcom_pcie_is_bridge_node(struct device_node *np)
+{
+	if (!of_node_is_type(np, "pci"))
+		return false;
+
+	return of_property_present(np, "bus-range") ||
+	       of_device_is_compatible(np, "pciclass,0604");
+}
+
+/* Parse PERST# from all PCIe bridge nodes starting from @np */
 static int qcom_pcie_parse_perst(struct qcom_pcie *pcie,
 				 struct qcom_pcie_port *port,
 				 struct device_node *np)
@@ -1731,6 +1740,9 @@ static int qcom_pcie_parse_perst(struct qcom_pcie *pcie,
 
 parse_child_node:
 	for_each_available_child_of_node_scoped(np, child) {
+		if (!qcom_pcie_is_bridge_node(child))
+			continue;
+
 		ret = qcom_pcie_parse_perst(pcie, port, child);
 		if (ret)
 			return ret;

---
base-commit: 735d2f48cadaa9a87e7c7601667878de70c771c5
change-id: 20260507-fix-qcom-pcie-parse-perst-a882f580a658

Best regards,
--  
Xilin Wu <sophon@radxa.com>
Re: [PATCH] PCI: qcom: Restrict PERST# parsing to PCI bridge nodes
Posted by Manivannan Sadhasivam 4 weeks ago
On Thu, May 07, 2026 at 10:18:31PM +0800, Xilin Wu wrote:
> Commit 2fd60a2edb83 ("PCI: qcom: Parse PERST# from all PCIe bridge
> nodes") extended PERST# parsing below the Root Port, so that downstream
> PCIe switch bridge nodes can describe their own PERST# GPIOs.
> 
> However, the implementation recurses into every available child node.  A
> PCI hierarchy may contain non-bridge child nodes with unrelated
> "reset-gpios" properties, such as an Ethernet PHY below an MDIO bus.  If
> such a reset GPIO is provided by a PCI endpoint GPIO controller, the
> endpoint has not been enumerated while the host bridge is still probing.
> Trying to acquire that GPIO then returns -EPROBE_DEFER and the Root Port
> probe is deferred indefinitely.
> 
> Only recurse into child nodes that are PCI bridge/bus nodes.  Keep parsing
> the Root Port passed by qcom_pcie_parse_port(), but filter descendants to
> nodes with device_type = "pci" and either a bus-range property or an
> explicit PCI bridge class compatible.
> 
> Fixes: 2fd60a2edb83 ("PCI: qcom: Parse PERST# from all PCIe bridge nodes")
> Signed-off-by: Xilin Wu <sophon@radxa.com>

This issue was already fixed by:
45df22935bdc ("PCI: qcom: Restrict port parsing only to PCIe bridge child nodes")

Could you please test v7.1-rc1 and confirm if the fix works for you?

- Mani

> ---
>  drivers/pci/controller/dwc/pcie-qcom.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c
> index af6bf5cce65b..5e0c31cc32a0 100644
> --- a/drivers/pci/controller/dwc/pcie-qcom.c
> +++ b/drivers/pci/controller/dwc/pcie-qcom.c
> @@ -1693,7 +1693,16 @@ static const struct pci_ecam_ops pci_qcom_ecam_ops = {
>  	}
>  };
>  
> -/* Parse PERST# from all nodes in depth first manner starting from @np */
> +static bool qcom_pcie_is_bridge_node(struct device_node *np)
> +{
> +	if (!of_node_is_type(np, "pci"))
> +		return false;
> +
> +	return of_property_present(np, "bus-range") ||
> +	       of_device_is_compatible(np, "pciclass,0604");
> +}
> +
> +/* Parse PERST# from all PCIe bridge nodes starting from @np */
>  static int qcom_pcie_parse_perst(struct qcom_pcie *pcie,
>  				 struct qcom_pcie_port *port,
>  				 struct device_node *np)
> @@ -1731,6 +1740,9 @@ static int qcom_pcie_parse_perst(struct qcom_pcie *pcie,
>  
>  parse_child_node:
>  	for_each_available_child_of_node_scoped(np, child) {
> +		if (!qcom_pcie_is_bridge_node(child))
> +			continue;
> +
>  		ret = qcom_pcie_parse_perst(pcie, port, child);
>  		if (ret)
>  			return ret;
> 
> ---
> base-commit: 735d2f48cadaa9a87e7c7601667878de70c771c5
> change-id: 20260507-fix-qcom-pcie-parse-perst-a882f580a658
> 
> Best regards,
> --  
> Xilin Wu <sophon@radxa.com>
> 

-- 
மணிவண்ணன் சதாசிவம்