public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: "Sherry Sun (OSS)" <sherry.sun@oss•nxp.com>
To: hongxing.zhu@nxp•com, l.stach@pengutronix•de, Frank.Li@nxp•com,
	bhelgaas@google•com, lpieralisi@kernel•org,
	kwilczynski@kernel•org, mani@kernel•org, robh@kernel•org,
	s.hauer@pengutronix•de, kernel@pengutronix•de,
	festevam@gmail•com, will@kernel•org
Cc: imx@lists•linux.dev, linux-pci@vger•kernel.org,
	linux-arm-kernel@lists•infradead.org,
	linux-kernel@vger•kernel.org, sherry.sun@nxp•com
Subject: [PATCH 2/2] PCI: imx6: Add imx_pcie_perst_found() to inspect the parsed result
Date: Fri, 22 May 2026 11:43:44 +0800	[thread overview]
Message-ID: <20260522034344.1147775-3-sherry.sun@oss.nxp.com> (raw)
In-Reply-To: <20260522034344.1147775-1-sherry.sun@oss.nxp.com>

From: Sherry Sun <sherry.sun@nxp•com>

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 to fall back to the legacy binding.
Add imx_pcie_perst_found() to inspect the parsed result.

Signed-off-by: Sherry Sun <sherry.sun@nxp•com>
---
 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



  parent reply	other threads:[~2026-05-22  3:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-22  3:43 [PATCH 0/2] PCI: imx6: Improve PERST# fallback logic Sherry Sun (OSS)
2026-05-22  3:43 ` [PATCH 1/2] PCI: host-generic: Simplify return value handling in pci_host_common_parse_port(s) Sherry Sun (OSS)
2026-05-22  6:05   ` Hongxing Zhu
2026-05-22  6:20     ` Sherry Sun
2026-05-22  3:43 ` Sherry Sun (OSS) [this message]
2026-05-22  6:05   ` [PATCH 2/2] PCI: imx6: Add imx_pcie_perst_found() to inspect the parsed result Hongxing Zhu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260522034344.1147775-3-sherry.sun@oss.nxp.com \
    --to=sherry.sun@oss$(echo .)nxp.com \
    --cc=Frank.Li@nxp$(echo .)com \
    --cc=bhelgaas@google$(echo .)com \
    --cc=festevam@gmail$(echo .)com \
    --cc=hongxing.zhu@nxp$(echo .)com \
    --cc=imx@lists$(echo .)linux.dev \
    --cc=kernel@pengutronix$(echo .)de \
    --cc=kwilczynski@kernel$(echo .)org \
    --cc=l.stach@pengutronix$(echo .)de \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linux-pci@vger$(echo .)kernel.org \
    --cc=lpieralisi@kernel$(echo .)org \
    --cc=mani@kernel$(echo .)org \
    --cc=robh@kernel$(echo .)org \
    --cc=s.hauer@pengutronix$(echo .)de \
    --cc=sherry.sun@nxp$(echo .)com \
    --cc=will@kernel$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox