U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Eichenberger <eichest@gmail.com>
To: trini@konsulko.com, ilias.apalodimas@linaro.org,
	sbabic@nabladev.com, festevam@gmail.com, uboot-imx@nxp.com,
	stefan.eichenberger@toradex.com, francesco.dolcini@toradex.com
Cc: u-boot@lists.u-boot-project.org
Subject: [PATCH v1 1/2] imx: mach: imx8: fdt: return libfdt errors from helpers
Date: Mon, 19 Oct 2026 14:58:52 +0200	[thread overview]
Message-ID: <20261019125930.111608-2-eichest@gmail.com> (raw)
In-Reply-To: <20261019125930.111608-1-eichest@gmail.com>

From: Stefan Eichenberger <stefan.eichenberger@toradex.com>

delete_node() and change_property() replaced the libfdt error codes with
-ENXIO and -EINVAL, but the callers pass the result to fdt_strerror(),
which expects a libfdt error code. In addition,
update_fdt_gpu_industrial_frequencies() compared the result against the
positive ENXIO, so a missing node was reported as an error instead of
being ignored.

On an industrial i.MX 8 booted with a device tree that lacks the GPU1
nodes (e.g. mainline Linux), a misleading error is printed on every boot
because -ENXIO is interpreted by fdt_strerror() as a libfdt error code,
e.g.:

    Failed to set assigned-clock-rates for GPU1: FDT_ERR_BADPHANDLE

Return the libfdt error codes unchanged and ignore -FDT_ERR_NOTFOUND,
which fdt_path_offset() returns if the node does not exist.

Fixes: e9cf7f515a19 ("imx: mach: imx8: fdt: set correct frequencies for the industrial SoC")
Signed-off-by: Stefan Eichenberger <stefan.eichenberger@toradex.com>
---
 arch/arm/mach-imx/imx8/fdt.c | 28 +++++++++-------------------
 1 file changed, 9 insertions(+), 19 deletions(-)

diff --git a/arch/arm/mach-imx/imx8/fdt.c b/arch/arm/mach-imx/imx8/fdt.c
index 8337edc2f62..630b5e55702 100644
--- a/arch/arm/mach-imx/imx8/fdt.c
+++ b/arch/arm/mach-imx/imx8/fdt.c
@@ -281,34 +281,24 @@ static int ft_add_optee_node(void *fdt, struct bd_info *bd)
 static int delete_node(void *blob, const char *node)
 {
 	int nodeoffset;
-	int err;
 
 	nodeoffset = fdt_path_offset(blob, node);
 	if (nodeoffset < 0)
-		return -ENXIO;
-
-	err = fdt_del_node(blob, nodeoffset);
-	if (err)
-		return -EINVAL;
+		return nodeoffset;
 
-	return 0;
+	return fdt_del_node(blob, nodeoffset);
 }
 
 static int change_property(void *blob, const char *node, const char *property,
 			   const void *value, int len)
 {
 	int nodeoffset;
-	int err;
 
 	nodeoffset = fdt_path_offset(blob, node);
 	if (nodeoffset < 0)
-		return -ENXIO;
-
-	err = fdt_setprop(blob, nodeoffset, property, value, len);
-	if (err)
-		return -EINVAL;
+		return nodeoffset;
 
-	return 0;
+	return fdt_setprop(blob, nodeoffset, property, value, len);
 }
 
 static void update_fdt_gpu_industrial_frequencies(void *blob)
@@ -330,21 +320,21 @@ static void update_fdt_gpu_industrial_frequencies(void *blob)
 	err = change_property(blob, "/bus@53100000/gpu@53100000",
 			      "assigned-clock-rates", gpu_assigned_clocks,
 			      sizeof(gpu_assigned_clocks));
-	if (err && err != ENXIO)
+	if (err && err != -FDT_ERR_NOTFOUND)
 		printf("Failed to set assigned-clock-rates for GPU0: %s\n",
 		       fdt_strerror(err));
 
 	err = change_property(blob, "/bus@54100000/gpu@54100000",
 			      "assigned-clock-rates", gpu_assigned_clocks,
 			      sizeof(gpu_assigned_clocks));
-	if (err && err != ENXIO)
+	if (err && err != -FDT_ERR_NOTFOUND)
 		printf("Failed to set assigned-clock-rates for GPU1: %s\n",
 		       fdt_strerror(err));
 
 	err = change_property(blob, "/bus@54100000/imx8_gpu1_ss@80000000",
 			      "operating-points", &gpu_opp_table,
 			      sizeof(gpu_opp_table));
-	if (err && err != ENXIO)
+	if (err && err != -FDT_ERR_NOTFOUND)
 		printf("Failed to set operating-points for GPU: %s\n",
 		       fdt_strerror(err));
 }
@@ -354,12 +344,12 @@ static void update_fdt_cpu_industrial_frequencies(void *blob)
 	int err;
 
 	err = delete_node(blob, "/opp-table-0/opp-1200000000");
-	if (err && err != -ENXIO)
+	if (err && err != -FDT_ERR_NOTFOUND)
 		printf("Failed to delete 1.2 GHz node on A53: %s\n",
 		       fdt_strerror(err));
 
 	err = delete_node(blob, "/opp-table-1/opp-1596000000");
-	if (err && err != -ENXIO)
+	if (err && err != -FDT_ERR_NOTFOUND)
 		printf("Failed to delete 1.596 GHz node on A72: %s\n",
 		       fdt_strerror(err));
 }
-- 
2.56.0


  reply	other threads:[~2026-10-19 13:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 12:58 [PATCH v1 0/2] imx: mach: imx8: fdt: fix industrial GPU frequencies Stefan Eichenberger
2026-10-19 12:58 ` Stefan Eichenberger [this message]
2026-10-20  5:31   ` [PATCH v1 1/2] imx: mach: imx8: fdt: return libfdt errors from helpers Francesco Dolcini
2026-10-19 12:58 ` [PATCH v1 2/2] imx: mach: imx8: fdt: support newer GPU0 bus node name Stefan Eichenberger
2026-10-20  5:40   ` Francesco Dolcini

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=20261019125930.111608-2-eichest@gmail.com \
    --to=eichest@gmail.com \
    --cc=festevam@gmail.com \
    --cc=francesco.dolcini@toradex.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=sbabic@nabladev.com \
    --cc=stefan.eichenberger@toradex.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    --cc=uboot-imx@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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