From: Sang-Heon Jeon <ekffu200098@gmail.com>
To: maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com,
chleroy@kernel.org, robh@kernel.org, saravanak@kernel.org
Cc: linuxppc-dev@lists.ozlabs.org, devicetree@vger.kernel.org,
Sang-Heon Jeon <ekffu200098@gmail.com>
Subject: [PATCH 1/2] powerpc/prom: fix /chosen properties read from wrong node
Date: Mon, 11 May 2026 02:13:52 +0900 [thread overview]
Message-ID: <20260510171353.1406018-2-ekffu200098@gmail.com> (raw)
In-Reply-To: <20260510171353.1406018-1-ekffu200098@gmail.com>
Commit 60f20d84dc81 ("of/fdt: Rework early_init_dt_scan_chosen() to
call directly") changed early_init_dt_scan_chosen() to be called
directly instead of via of_scan_flat_dt(). After this change,
early_init_dt_scan_chosen_ppc() does not behave as intended in either
case below:
- /chosen(or /chosen@0) exists: early_init_dt_scan_chosen() always
succeeds, so early_init_dt_scan_chosen_ppc() then reads properties
from the root node (first iteration) instead of chosen node.
- /chosen does not exist:
- Until commit 064e32dc5b03 ("of: fdt: Honor CONFIG_CMDLINE* even without
/chosen node, take 2"), early_init_dt_scan_chosen() returns -ENOENT
and early_init_dt_scan_chosen_ppc() returns 0. So of_scan_flat_dt()
iterates over all remaining nodes. Not a bug but unnecessary.
- After above commit, early_init_dt_scan_chosen() returns 0 and
early_init_dt_scan_chosen_ppc() returns 1. So it reads properties
from the root node (first iteration) instead of chosen node, same as
the chosen node exist case above.
Instead of using of_scan_flat_dt() for chosen node handling, first call
early_init_dt_scan_chosen() directly to handle common chosen node
properties. Then call early_init_dt_scan_chosen_ppc(), which is updated
to handle powerpc-specific chosen node properties.
Both now look up chosen node directly to avoid reading from the wrong node.
Fixes: 60f20d84dc81 ("of/fdt: Rework early_init_dt_scan_chosen() to call directly")
Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
QEMU-based test results
$ fdtput -t bx chosen.dtb /chosen linux,crashkernel-base 00 00 00 10 00 00 00 00
$ fdtput -t bx chosen.dtb /chosen linux,crashkernel-size 00 00 00 02 00 00 00 00
$ qemu-system-ppc64 -M powernv9,dtb=chosen.dtb ...
1) AS-IS (before fix)
# cat /sys/kernel/kexec_crash_size
0
2) TO-BE (after fix)
# cat /sys/kernel/kexec_crash_size
33554432
---
arch/powerpc/kernel/prom.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 9ed9dde7d231..34318ddb4a73 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -450,15 +450,17 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
return 0;
}
-static int __init early_init_dt_scan_chosen_ppc(unsigned long node,
- const char *uname,
- int depth, void *data)
+static void __init early_init_dt_scan_chosen_ppc(void)
{
+ const void *fdt = initial_boot_params;
const unsigned long *lprop; /* All these set by kernel, so no need to convert endian */
+ int node;
- /* Use common scan routine to determine if this is the chosen node */
- if (early_init_dt_scan_chosen(data) < 0)
- return 0;
+ node = fdt_path_offset(fdt, "/chosen");
+ if (node < 0)
+ node = fdt_path_offset(fdt, "/chosen@0");
+ if (node < 0)
+ return;
#ifdef CONFIG_PPC64
/* check if iommu is forced on or off */
@@ -491,9 +493,6 @@ static int __init early_init_dt_scan_chosen_ppc(unsigned long node,
if (lprop)
crashk_res.end = crashk_res.start + *lprop - 1;
#endif
-
- /* break now */
- return 1;
}
/*
@@ -818,7 +817,8 @@ void __init early_init_devtree(void *params)
* device-tree, including the platform type, initrd location and
* size, TCE reserve, and more ...
*/
- of_scan_flat_dt(early_init_dt_scan_chosen_ppc, boot_command_line);
+ early_init_dt_scan_chosen(boot_command_line);
+ early_init_dt_scan_chosen_ppc();
/* Append additional parameters passed for fadump capture kernel */
fadump_append_bootargs();
--
2.43.0
next prev parent reply other threads:[~2026-05-10 17:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-10 17:13 [PATCH 0/2] powerpc/prom, of/fdt: fix chosen node handling and cleanup Sang-Heon Jeon
2026-05-10 17:13 ` Sang-Heon Jeon [this message]
2026-05-10 17:13 ` [PATCH 2/2] of/fdt: make early_init_dt_scan_chosen() return void Sang-Heon Jeon
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=20260510171353.1406018-2-ekffu200098@gmail.com \
--to=ekffu200098@gmail.com \
--cc=chleroy@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=robh@kernel.org \
--cc=saravanak@kernel.org \
/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