riscv: Fix arch_fixup_fdt always failing without /chosen
PATCH 1/1 riscv: Fix arch_fixup_fdt always failing without /chosen
If /chosen was missing, chosen_offset would never get updated with the new /chosen node. This would cause fdt_setprop_u32 to fail. This patch fixes this by setting chosen_offset. In addition, log any errors from setting boot-hartid as well.
---
I have not actually tested this (nor observed the original failure). But this seemed buggy from inspection.
arch/riscv/lib/fdt_fixup.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
arch/riscv/lib/fdt_fixup.c +7 -4
@@ -151,14 +151,17 @@ int arch_fixup_fdt(void *blob) } chosen_offset =fdt_path_offset (blob,"/chosen" );if (chosen_offset <0 ) { - err =fdt_add_subnode (blob,0 ,"chosen" ); -if (err <0 ) { + chosen_offset =fdt_add_subnode (blob,0 ,"chosen" ); +if (chosen_offset <0 ) {log_err ("chosen node cannot be added\n" ); -return err; +return chosen_offset; } }/* Overwrite the boot-hartid as U-Boot is the last stage BL */ -fdt_setprop_u32 (blob, chosen_offset,"boot-hartid" , gd->arch.boot_hart); + err =fdt_setprop_u32 (blob, chosen_offset,"boot-hartid" , + gd->arch.boot_hart); +if (err <0 ) +return log_msg_ret ("could not set boot-hartid" , err);#endif /* Copy the reserved-memory node to the DT used by OS */
Signature · 1 line
2.31.0
PATCH 1/1 riscv: Fix arch_fixup_fdt always failing without /chosen
Quoted 7 lines · Sean Anderson
If /chosen was missing,
chosen_offsetwould never get updated with the new /chosen node. This would causefdt_setprop_u32to fail. This patch fixes this by settingchosen_offset. In addition, log any errors from setting boot-hartid as well.Fixes 177c53fe6c6 ("riscv: Move all fdt fixups together")
I think the correct commit id to fix is:
commit 5370478d1c7afb8b2a8a0a00b31ff97c3a2c0451 ("riscv: Add boot hartid to device tree")
Quoted 25 lines
Signed-off-by Sean Anderson <[email protected]>---
I have not actually tested this (nor observed the original failure). But this seemed buggy from inspection.arch/riscv/lib/fdt_fixup.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)arch/riscv/lib/fdt_fixup.c +3
-3@@ -151,14 +151,17 @@ int arch_fixup_fdt(void *blob) } chosen_offset =fdt_path_offset (blob,"/chosen" );if (chosen_offset <0 ) { - err =fdt_add_subnode (blob,0 ,"chosen" ); -if (err <0 ) { + chosen_offset =fdt_add_subnode (blob,0 ,"chosen" ); +if (chosen_offset <0 ) {log_err ("chosen node cannot be added\n" ); -return err; +return chosen_offset; } }
arch/riscv/lib/fdt_fixup.c int arch_fixup_fdt(void *blob)
Quoted 10 lines
arch/riscv/lib/fdt_fixup.c +4
-2/* Overwrite the boot-hartid as U-Boot is the last stage BL */ -fdt_setprop_u32 (blob, chosen_offset,"boot-hartid" , gd->arch.boot_hart); + err =fdt_setprop_u32 (blob, chosen_offset,"boot-hartid" , + gd->arch.boot_hart); +if (err <0 ) +return log_msg_ret ("could not set boot-hartid" , err);#endif /* Copy the reserved-memory node to the DT used by OS */ --
PATCH 1/1 riscv: Fix arch_fixup_fdt always failing without /chosen
Quoted 7 lines · Bin Meng
Quoted 6 lines · Sean Anderson
If /chosen was missing,
chosen_offsetwould never get updated with the new /chosen node. This would causefdt_setprop_u32to fail. This patch fixes this by settingchosen_offset. In addition, log any errors from setting boot-hartid as well.
Quoted 5 lines
Quoted 1 line
Fixes 177c53fe6c6 ("riscv: Move all fdt fixups together")I think the correct commit id to fix is:
commit5370478d1c7afb8b2a8a0a00b31ff97c3a2c0451("riscv: Add boot hartid to device tree")
Ah, so it is.
--Sean
Quoted 39 lines
Quoted 26 lines
Signed-off-by Sean Anderson <[email protected]>---
I have not actually tested this (nor observed the original failure). But this seemed buggy from inspection.arch/riscv/lib/fdt_fixup.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)arch/riscv/lib/fdt_fixup.c +3
-3@@ -151,14 +151,17 @@ int arch_fixup_fdt(void *blob) } chosen_offset =fdt_path_offset (blob,"/chosen" );if (chosen_offset <0 ) { - err =fdt_add_subnode (blob,0 ,"chosen" ); -if (err <0 ) { + chosen_offset =fdt_add_subnode (blob,0 ,"chosen" ); +if (chosen_offset <0 ) {log_err ("chosen node cannot be added\n" ); -return err; +return chosen_offset; } }arch/riscv/lib/fdt_fixup.c int arch_fixup_fdt(void *blob)
Quoted 10 lines
arch/riscv/lib/fdt_fixup.c +4
-2/* Overwrite the boot-hartid as U-Boot is the last stage BL */ -fdt_setprop_u32 (blob, chosen_offset,"boot-hartid" , gd->arch.boot_hart); + err =fdt_setprop_u32 (blob, chosen_offset,"boot-hartid" , + gd->arch.boot_hart); +if (err <0 ) +return log_msg_ret ("could not set boot-hartid" , err);#endif /* Copy the reserved-memory node to the DT used by OS */ --Reviewed-by Bin Meng <[email protected]>
PATCH 1/1 riscv: Fix arch_fixup_fdt always failing without /chosen
Hi Sean,
Quoted 9 lines · Sean Anderson
Quoted 7 lines · Bin Meng
Quoted 6 lines · Sean Anderson
If /chosen was missing,
chosen_offsetwould never get updated with the new /chosen node. This would causefdt_setprop_u32to fail. This patch fixes this by settingchosen_offset. In addition, log any errors from setting boot-hartid as well.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Fixes 177c53fe6c6 ("riscv: Move all fdt fixups together")I think the correct commit id to fix is:
commit5370478d1c7afb8b2a8a0a00b31ff97c3a2c0451("riscv: Add boot hartid to device tree")Ah, so it is.
Would you send v2 with the correct commit id?
Regards,
Bin
PATCH 1/1 riscv: Fix arch_fixup_fdt always failing without /chosen
In reply to Sean AndersonQuoted 5 lines
If /chosen was missing,
chosen_offsetwould never get updated with the new /chosen node. This would causefdt_setprop_u32to fail. This patch fixes this by settingchosen_offset. In addition, log any errors from setting boot-hartid as well.
Quoted 8 lines
Fixes 177c53fe6c6 ("riscv: Move all fdt fixups together")Signed-off-by Sean Anderson <[email protected]>---
I have not actually tested this (nor observed the original failure). But this seemed buggy from inspection.arch/riscv/lib/fdt_fixup.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
Good catch !
PATCH 1/1 riscv: Fix arch_fixup_fdt always failing without /chosen
In reply to Sean AndersonQuoted 42 lines · Sean Anderson
If /chosen was missing,
chosen_offsetwould never get updated with the new /chosen node. This would causefdt_setprop_u32to fail. This patch fixes this by settingchosen_offset. In addition, log any errors from setting boot-hartid as well.Fixes 177c53fe6c6 ("riscv: Move all fdt fixups together")Signed-off-by Sean Anderson <[email protected]>---
I have not actually tested this (nor observed the original failure). But this seemed buggy from inspection.arch/riscv/lib/fdt_fixup.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)arch/riscv/lib/fdt_fixup.c +7
-5@@ -151,14 +151,17 @@ int arch_fixup_fdt(void *blob) } chosen_offset =fdt_path_offset (blob,"/chosen" );if (chosen_offset <0 ) { - err =fdt_add_subnode (blob,0 ,"chosen" ); -if (err <0 ) { + chosen_offset =fdt_add_subnode (blob,0 ,"chosen" ); +if (chosen_offset <0 ) {log_err ("chosen node cannot be added\n" ); -return err; +return chosen_offset; } }/* Overwrite the boot-hartid as U-Boot is the last stage BL */ -fdt_setprop_u32 (blob, chosen_offset,"boot-hartid" , gd->arch.boot_hart); + err =fdt_setprop_u32 (blob, chosen_offset,"boot-hartid" , + gd->arch.boot_hart); +if (err <0 ) +return log_msg_ret ("could not set boot-hartid" , err);#endif /* Copy the reserved-memory node to the DT used by OS */ --
Quoted 2 lines
2.31.0
Thanks for the fix. Good catch.
With update commit text as suggested by Bin:
Signature · 2 lines
Regards, Atish