MIPS: OCTEON: Fix the boot broken when using built-in DTB
PATCH 1/1 MIPS: OCTEON: Fix the boot broken when using built-in DTB
For the OCTEON boards, it need to patch the built-in DTB before using it. Previously it judges if it is a built-in DTB by checking fw_passed_dtb. But after commit 37e5c69ffd41 ("MIPS: head.S: Init fw_passed_dtb to builtin DTB", the fw_passed_dtb is initialized even when using built-in DTB. This causes the OCTEON boards boot broken due to an unpatched built-in DTB is used. Add more checks to judge if we really use built-in DTB or not.
Fixed: 37e5c69ffd41 ("MIPS: head.S: Init fw_passed_dtb to builtin DTB")
--- arch/mips/cavium-octeon/setup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/cavium-octeon/setup.c +2 -1
@@ -1149,7 +1149,8 @@ void __init device_tree_init(void)bool do_prune;bool fill_mac; -if (fw_passed_dtb) { +if (fw_passed_dtb && (fw_passed_dtb != (ulong)&__dtb_octeon_68xx_begin) && + (fw_passed_dtb != (ulong)&__dtb_octeon_3xxx_begin)) { fdt = (void *)fw_passed_dtb; do_prune = false; fill_mac = true;
Signature · 1 line
2.29.2
Thomas Bogendoerfer
maintainerQuoted 20 lines · Kevin Hao
For the OCTEON boards, it need to patch the built-in DTB before using it. Previously it judges if it is a built-in DTB by checking
fw_passed_dtb. But after commit37e5c69ffd41("MIPS:head.S: Initfw_passed_dtbto builtin DTB", thefw_passed_dtbis initialized even when using built-in DTB. This causes the OCTEON boards boot broken due to an unpatched built-in DTB is used. Add more checks to judge if we really use built-in DTB or not.Fixed:
37e5c69ffd41("MIPS:head.S: Initfw_passed_dtbto builtin DTB")Signed-off-by Kevin Hao <[email protected]>--- arch/mips/cavium-octeon/setup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/mips/cavium-octeon/setup.c +0
-0
arch/mips/cavium-octeon/setup.c void __init device_tree_init(void) · line 1153
Quoted 6 lines
arch/mips/cavium-octeon/setup.c +2
-1@@ -1149,7 +1149,8 @@ void __init device_tree_init(void)bool do_prune;bool fill_mac; -if (fw_passed_dtb) { +if (fw_passed_dtb && (fw_passed_dtb != (ulong)&__dtb_octeon_68xx_begin) && + (fw_passed_dtb != (ulong)&__dtb_octeon_3xxx_begin)) {
well, if someone add a third dtb do the builtin DTBs, this might fail again. Let's fix it for real...
arch/mips/cavium-octeon/setup.c void __init device_tree_init(void) · line 1156
Quoted 3 lines
arch/mips/cavium-octeon/setup.c +0
-0fdt = (void *)fw_passed_dtb; do_prune = false; fill_mac = true;
.... IMHO the real bug is d9df9fb901d2 MIPS: Octeon: Remove special handling of CONFIG_MIPS_ELF_APPENDED_DTB=y. I'm tending to simply revert that commit. A different option would be to not place the two __dtb_octeon dtbs into the builtin dtb section, which looks like more work for not much gain...
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]
Quoted 31 lines · Thomas Bogendoerfer
Quoted 20 lines · Kevin Hao
For the OCTEON boards, it need to patch the built-in DTB before using it. Previously it judges if it is a built-in DTB by checking
fw_passed_dtb. But after commit37e5c69ffd41("MIPS:head.S: Initfw_passed_dtbto builtin DTB", thefw_passed_dtbis initialized even when using built-in DTB. This causes the OCTEON boards boot broken due to an unpatched built-in DTB is used. Add more checks to judge if we really use built-in DTB or not.Fixed:
37e5c69ffd41("MIPS:head.S: Initfw_passed_dtbto builtin DTB")Signed-off-by Kevin Hao <[email protected]>--- arch/mips/cavium-octeon/setup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/mips/cavium-octeon/setup.c +0
-0arch/mips/cavium-octeon/setup.c void __init device_tree_init(void) · line 1153
Quoted 6 lines
arch/mips/cavium-octeon/setup.c +2
-1@@ -1149,7 +1149,8 @@ void __init device_tree_init(void)bool do_prune;bool fill_mac; -if (fw_passed_dtb) { +if (fw_passed_dtb && (fw_passed_dtb != (ulong)&__dtb_octeon_68xx_begin) && + (fw_passed_dtb != (ulong)&__dtb_octeon_3xxx_begin)) {well, if someone add a third dtb do the builtin DTBs, this might fail again. Let's fix it for real...
Quoted 6 lines
arch/mips/cavium-octeon/setup.c void __init device_tree_init(void) · line 1156
Quoted 3 lines
arch/mips/cavium-octeon/setup.c +0
-0fdt = (void *)fw_passed_dtb; do_prune = false; fill_mac = true;.... IMHO the real bug is
d9df9fb901d2MIPS: Octeon: Remove special handling ofCONFIG_MIPS_ELF_APPENDED_DTB=y. I'm tending to simply revert that commit.
Yes, this indeed seem much better. I will send a patch to revert d9df9fb901d2. Another issue is that the name of fw_passed_dtb seems pretty confusion after the change of commit 37e5c69ffd41. Could we rename it to something like final_dtb_addr?
Thanks,
Kevin
Quoted 8 lines
A different option would be to not place the two
__dtb_octeondtbs into the builtin dtb section, which looks like more work for not much gain...Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]
Thomas Bogendoerfer
maintainerQuoted 6 lines · Kevin Hao
Quoted 2 lines
.... IMHO the real bug is
d9df9fb901d2MIPS: Octeon: Remove special handling ofCONFIG_MIPS_ELF_APPENDED_DTB=y. I'm tending to simply revert that commit.Yes, this indeed seem much better. I will send a patch to revert
d9df9fb901d2. Another issue is that the name offw_passed_dtbseems pretty confusion after the change of commit37e5c69ffd41. Could we rename it to something likefinal_dtb_addr?
this wouldn't make the mess smaller, IMHO. My idea is to add a helper function, which deals with all the possible sources of dtbs, which could be used instead of fw_passed_dtb. This gets rid of the ugly #ifdefry in head.S and hopefull makes future changes less error prone.
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]