Hello,
While looking into boot information, I found one bug fix and one
minor cleanup around /chosen node handling.
Patch 1 fixes a bug in powerpc where /chosen properties are read
from the wrong node.
This bug has existed for a while without any report, so I don't
think backporting is necessary and I did not add Cc: stable.
Please let me know if you think otherwise.
Patch 2 is a follow-up cleanup that drops the now-unused return
value of early_init_dt_scan_chosen() and the dead checks at its
callers.
If I missunderstood anything, please feel free to let me know.
Best Regards,
Sang-Heon Jeon
Sang-Heon Jeon (2):
powerpc/prom: fix /chosen properties read from wrong node
of/fdt: make early_init_dt_scan_chosen() return void
arch/powerpc/kernel/prom.c | 20 ++++++++++----------
drivers/of/fdt.c | 10 ++--------
include/linux/of_fdt.h | 2 +-
3 files changed, 13 insertions(+), 19 deletions(-)
--
2.43.0
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 <redacted>
---
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(-)
@@ -450,15 +450,17 @@ static int __init early_init_dt_scan_cpus(unsigned long node,return0;}-staticint__initearly_init_dt_scan_chosen_ppc(unsignedlongnode,-constchar*uname,-intdepth,void*data)+staticvoid__initearly_init_dt_scan_chosen_ppc(void){+constvoid*fdt=initial_boot_params;constunsignedlong*lprop;/* All these set by kernel, so no need to convert endian */+intnode;-/* Use common scan routine to determine if this is the chosen node */-if(early_init_dt_scan_chosen(data)<0)-return0;+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 */-return1;}/*
Since commit 064e32dc5b03 ("of: fdt: Honor CONFIG_CMDLINE* even
without /chosen node, take 2"), early_init_dt_scan_chosen() always
returns 0, so the return value checks at its callers have become
dead code.
Drop the return value, change the function to return void, and
update its declaration and callers accordingly. No functional
change.
Signed-off-by: Sang-Heon Jeon <redacted>
---
dt-test result
[ 0.684136] ### dt-test ### start of unittest - you will see error messages
[ 0.685849] ### dt-test ### EXPECT \ : Duplicate name in testcase-data, renamed to "duplicate-name#1"
[ 0.685870] Duplicate name in testcase-data, renamed to "duplicate-name#1"
[ 0.689496] ### dt-test ### EXPECT / : Duplicate name in testcase-data, renamed to "duplicate-name#1"
...
[ 1.693384] ### dt-test ### EXPECT / : OF: resolver: overlay phandle fixup failed: -22
[ 1.693386] ### dt-test ### EXPECT / : OF: resolver: node label 'this_label_does_not_exist' not found in live devicetree symbols table
[ 1.694968] ### dt-test ### end of unittest - 405 passed, 0 failed
---
drivers/of/fdt.c | 10 ++--------
include/linux/of_fdt.h | 2 +-
2 files changed, 3 insertions(+), 9 deletions(-)
@@ -1087,7 +1087,7 @@ int __init early_init_dt_scan_memory(void)returnfound_memory;}-int__initearly_init_dt_scan_chosen(char*cmdline)+void__initearly_init_dt_scan_chosen(char*cmdline){intl,node;constchar*p;
@@ -1144,8 +1144,6 @@ int __init early_init_dt_scan_chosen(char *cmdline)#endif /* CONFIG_CMDLINE */pr_debug("Command line is: %s\n",(char*)cmdline);--return0;}#ifndef MIN_MEMBLOCK_ADDR
@@ -1226,12 +1224,8 @@ bool __init early_init_dt_verify(void *dt_virt, phys_addr_t dt_phys)void__initearly_init_dt_scan_nodes(void){-intrc;-/* Retrieve various information from the /chosen node */-rc=early_init_dt_scan_chosen(boot_command_line);-if(rc)-pr_warn("No chosen node found, continuing without\n");+early_init_dt_scan_chosen(boot_command_line);/* Setup memory, calling early_init_dt_add_memory_arch */early_init_dt_scan_memory();
From: Rob Herring <robh@kernel.org> Date: 2026-06-01 22:01:43
On Mon, May 11, 2026 at 02:13:52AM +0900, Sang-Heon Jeon wrote:
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 <redacted>
From: Rob Herring <robh@kernel.org> Date: 2026-06-01 22:03:47
On Mon, May 11, 2026 at 02:13:53AM +0900, Sang-Heon Jeon wrote:
Since commit 064e32dc5b03 ("of: fdt: Honor CONFIG_CMDLINE* even
without /chosen node, take 2"), early_init_dt_scan_chosen() always
returns 0, so the return value checks at its callers have become
dead code.
Drop the return value, change the function to return void, and
update its declaration and callers accordingly. No functional
change.
Signed-off-by: Sang-Heon Jeon <redacted>
---
dt-test result
[ 0.684136] ### dt-test ### start of unittest - you will see error messages
[ 0.685849] ### dt-test ### EXPECT \ : Duplicate name in testcase-data, renamed to "duplicate-name#1"
[ 0.685870] Duplicate name in testcase-data, renamed to "duplicate-name#1"
[ 0.689496] ### dt-test ### EXPECT / : Duplicate name in testcase-data, renamed to "duplicate-name#1"
...
[ 1.693384] ### dt-test ### EXPECT / : OF: resolver: overlay phandle fixup failed: -22
[ 1.693386] ### dt-test ### EXPECT / : OF: resolver: node label 'this_label_does_not_exist' not found in live devicetree symbols table
[ 1.694968] ### dt-test ### end of unittest - 405 passed, 0 failed
---
drivers/of/fdt.c | 10 ++--------
include/linux/of_fdt.h | 2 +-
2 files changed, 3 insertions(+), 9 deletions(-)
Looks like this is dependent on patch 1, so I'm assuming the PPC folks
will take the series.
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Hello,
On Tue, Jun 2, 2026 at 7:03 AM Rob Herring [off-list ref] wrote:
On Mon, May 11, 2026 at 02:13:53AM +0900, Sang-Heon Jeon wrote:
quoted
Since commit 064e32dc5b03 ("of: fdt: Honor CONFIG_CMDLINE* even
without /chosen node, take 2"), early_init_dt_scan_chosen() always
returns 0, so the return value checks at its callers have become
dead code.
Drop the return value, change the function to return void, and
update its declaration and callers accordingly. No functional
change.
Signed-off-by: Sang-Heon Jeon <redacted>
---
dt-test result
[ 0.684136] ### dt-test ### start of unittest - you will see error messages
[ 0.685849] ### dt-test ### EXPECT \ : Duplicate name in testcase-data, renamed to "duplicate-name#1"
[ 0.685870] Duplicate name in testcase-data, renamed to "duplicate-name#1"
[ 0.689496] ### dt-test ### EXPECT / : Duplicate name in testcase-data, renamed to "duplicate-name#1"
...
[ 1.693384] ### dt-test ### EXPECT / : OF: resolver: overlay phandle fixup failed: -22
[ 1.693386] ### dt-test ### EXPECT / : OF: resolver: node label 'this_label_does_not_exist' not found in live devicetree symbols table
[ 1.694968] ### dt-test ### end of unittest - 405 passed, 0 failed
---
drivers/of/fdt.c | 10 ++--------
include/linux/of_fdt.h | 2 +-
2 files changed, 3 insertions(+), 9 deletions(-)
Looks like this is dependent on patch 1, so I'm assuming the PPC folks
will take the series.
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Thanks for reviewing, Rob :)
The merge window is now open. PPC folks, could you take a look and
pick this series up for 7.2?
Best Regards,
Sang-Heon Jeon