RE: [PATCH 2/2] PCI: imx6: Add imx_pcie_perst_found() to inspect the parsed result

From: Hongxing Zhu

Date: Fri May 22 2026 - 02:05:52 EST


> -----Original Message-----
> From: Sherry Sun (OSS) <sherry.sun@xxxxxxxxxxx>
> Sent: Friday, May 22, 2026 11:44 AM
> To: Hongxing Zhu <hongxing.zhu@xxxxxxx>; l.stach@xxxxxxxxxxxxxx; Frank Li
> <frank.li@xxxxxxx>; bhelgaas@xxxxxxxxxx; lpieralisi@xxxxxxxxxx;
> kwilczynski@xxxxxxxxxx; mani@xxxxxxxxxx; robh@xxxxxxxxxx;
> s.hauer@xxxxxxxxxxxxxx; kernel@xxxxxxxxxxxxxx; festevam@xxxxxxxxx;
> will@xxxxxxxxxx
> Cc: imx@xxxxxxxxxxxxxxx; linux-pci@xxxxxxxxxxxxxxx; linux-arm-
> kernel@xxxxxxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; Sherry Sun
> <sherry.sun@xxxxxxx>
> Subject: [PATCH 2/2] PCI: imx6: Add imx_pcie_perst_found() to inspect the
> parsed result
>
> From: Sherry Sun <sherry.sun@xxxxxxx>
>
> Since pci_host_common_parse_port() doesn't return failure for "property not
> found"(-ENODEV), the caller should inspect the parsed result and decide whether
One space should be placed before (-ENODEV).

> to fall back to the legacy binding.
> Add imx_pcie_perst_found() to inspect the parsed result.
>
> Signed-off-by: Sherry Sun <sherry.sun@xxxxxxx>
Reviewed-by: Richard Zhu <hongxing.zhu@xxxxxxx>

Best Regards
Richard Zhu

> ---
> drivers/pci/controller/dwc/pci-imx6.c | 25 +++++++++++++++++--------
> 1 file changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c
> b/drivers/pci/controller/dwc/pci-imx6.c
> index b137551871fc..34756f28fcc6 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
> @@ -1287,6 +1287,18 @@ static void imx_pcie_assert_perst(struct imx_pcie
> *imx_pcie, bool assert)
> }
> }
>
> +static bool imx_pcie_perst_found(struct pci_host_bridge *bridge) {
> + struct pci_host_port *port;
> +
> + list_for_each_entry(port, &bridge->ports, list) {
> + if (!list_empty(&port->perst))
> + return true;
> + }
> +
> + return false;
> +}
> +
> static int imx_pcie_host_init(struct dw_pcie_rp *pp) {
> struct dw_pcie *pci = to_dw_pcie_from_pp(pp); @@ -1299,15 +1311,12
> @@ static int imx_pcie_host_init(struct dw_pcie_rp *pp)
> /* Parse Root Port nodes if present */
> ret = pci_host_common_parse_ports(dev, bridge);
> if (ret) {
> - if (ret != -ENODEV) {
> - dev_err(dev, "Failed to parse Root Port
> nodes: %d\n", ret);
> - return ret;
> - }
> + dev_err(dev, "Failed to parse Root Port nodes: %d\n",
> ret);
> + return ret;
> + }
>
> - /*
> - * Fall back to legacy binding for DT backwards
> - * compatibility
> - */
> + /* Fallback to legacy binding for DT backwards compatibility. */
> + if (!imx_pcie_perst_found(bridge)) {
> ret = imx_pcie_parse_legacy_binding(imx_pcie);
> if (ret)
> return ret;
> --
> 2.37.1