v2023.07-rc5 regression: Image overlaps SPL
Subsystems (2)
Hello Marek,
as briefly discussed off-list it looks like
commit 77aed22b48ab ("spl: spl_legacy: Add extra address checks") introduces a regression on some board/arch, at least colibri and apalis imx6 fails to boot now
``` Trying to boot from MMC1 SPL: Image overlaps SPL resetting ... ```
From a quick check verdin imx8mm and imx8mp are not affected.
I also noticed something weird on a colibri imx7s, this is not using SPL, likely something completly different, however given this is new also from rc5 I thought it's valuable to report:
``` U-Boot 2023.07-rc5-0.0.0-devel+git.580eb31199be (Jun 27 2023 - 13:39:58 +0000) CPU: Freescale i.MX7S rev1.2 800 MHz (running at 792 MHz) CPU: Extended Commercial temperature grade (-20C to 105C) at 30C Reset cause: POR DRAM: initcall sequence 8786eafc failed at call 8781b351 (err=-3) ### ERROR ### Please RESET the board ### ```
Currently at the EOSS in Prague, so no way to do more testing/debugging, but I tought it was better to start reporting this on the list since we are getting close to the actual release.
Francesco
Quoted 26 lines · Francesco Dolcini
Hello Marek,
as briefly discussed off-list it looks like
commit77aed22b48ab("spl:spl_legacy: Add extra address checks") introduces a regression on some board/arch, at least colibri and apalis imx6 fails to boot now``` Trying to boot from MMC1 SPL: Image overlaps SPL resetting ... ```From a quick check verdin imx8mm and imx8mp are not affected.
I also noticed something weird on a colibri imx7s, this is not using SPL, likely something completly different, however given this is new also from rc5 I thought it's valuable to report:
``` U-Boot 2023.07-rc5-0.0.0-devel+git.580eb31199be (Jun 27 2023 - 13:39:58 +0000) CPU: Freescale i.MX7S rev1.2 800 MHz (running at 792 MHz) CPU: Extended Commercial temperature grade (-20C to 105C) at 30C Reset cause: POR DRAM: initcall sequence 8786eafc failed at call 8781b351 (err=-3) ### ERROR ### Please RESET the board ### ```
Quoted 3 lines
Currently at the EOSS in Prague, so no way to do more testing/debugging, but I tought it was better to start reporting this on the list since we are getting close to the actual release.
Well ugh. And my mx6cuboxi was out of my CI loop so I didn't see this at the time. Does reverting just the legacy checks patch fix the i.MX7 case as well?
Signature · 1 line
Tom
Quoted 14 lines · Tom Rini
Quoted 13 lines · Francesco Dolcini
I also noticed something weird on a colibri imx7s, this is not using SPL, likely something completly different, however given this is new also from rc5 I thought it's valuable to report:
``` U-Boot 2023.07-rc5-0.0.0-devel+git.580eb31199be (Jun 27 2023 - 13:39:58 +0000) CPU: Freescale i.MX7S rev1.2 800 MHz (running at 792 MHz) CPU: Extended Commercial temperature grade (-20C to 105C) at 30C Reset cause: POR DRAM: initcall sequence 8786eafc failed at call 8781b351 (err=-3) ### ERROR ### Please RESET the board ### ```
Quoted 7 lines
Quoted 3 lines
Currently at the EOSS in Prague, so no way to do more testing/debugging, but I tought it was better to start reporting this on the list since we are getting close to the actual release.
Well ugh. And my mx6cuboxi was out of my CI loop so I didn't see this at the time. Does reverting just the legacy checks patch fix the i.MX7 case as well?
I would assume this is unrelated, since there is no SPL involved there. I'll try to get more information in the next days.
Francesco
Fabio Estevam
reviewerHi Francesco and Marek,
Quoted 10 lines · Francesco Dolcini
Hello Marek,
as briefly discussed off-list it looks like
commit77aed22b48ab("spl:spl_legacy: Add extra address checks") introduces a regression on some board/arch, at least colibri and apalis imx6 fails to boot now```
Trying to boot from MMC1
SPL: Image overlaps SPL
resetting ...
I was able to reproduce this problem on an imx6dl colibri and added some debug information:
Trying to boot from USB SDP
SDP: initialize...
SDP: handle requests...
Downloading file of size 551176 to 0x177fffc0... done Jumping to header at 0x177fffc0
Header Tag is not an IMX image
Found header at 0x177fffc0
********* start: 0x177fffc0
********* size: 0x86908
********* spl_start: 0x908000
********* spl_end: 0x18200480
********* end: 0x178868c8
SPL: Image overlaps SPL
Please note that spl_start is inside internal RAM space, but spl_end points to a DDR address.
Should we fix spl_end like this?
common/spl/spl_legacy.c +1 -1
@@ -19,9 +19,17 @@static void spl_parse_legacy_validate (uintptr_t start,uintptr_t size) {uintptr_t spl_start = (uintptr_t )_start; -uintptr_t spl_end = (uintptr_t )__bss_end; +uintptr_t spl_end = spl_start + size;uintptr_t end = start + size;
Fabio Estevam
reviewerQuoted 1 line · Fabio Estevam
Should we fix
spl_endlike this?
Looking at u-boot-spl.map:
0x0000000000912264 0x0 common/spl/spl.o
0x0000000000912264 . = ALIGN (0x4)
0x0000000000912264 __image_copy_end = ..end
*(.__end)
0x0000000000912264 _image_binary_end = .
__image_copy_end is the last address of the SPL inside the internal RAM.
So shouldn't we do this instead?
common/spl/spl_legacy.c +1 -1
@@ -19,9 +19,17 @@static void spl_parse_legacy_validate (uintptr_t start,uintptr_t size) {uintptr_t spl_start = (uintptr_t )_start; -uintptr_t spl_end = (uintptr_t )__bss_end; +uintptr_t spl_end = (uintptr_t )__image_copy_end;uintptr_t end = start + size;
Which results in:
********* start: 0x177fffc0
********* size: 0x86908
********* spl_start: 0x908000
********* spl_end: 0x912264
********* end: 0x178868c8
********* start: 0x17800000
********* size: 0x0
********* spl_start: 0x908000
********* spl_end: 0x912264
********* end: 0x17800000
and allows the boot to proceed:
U-Boot 2023.07-rc5-00012-g5fa30f2351ac-dirty (Jun 30 2023 - 10:45:40 -0300)
CPU: Freescale i.MX6DL rev1.4 at 792MHz CPU: Industrial temperature grade (-40C to 105C) at 46C
Quoted 21 lines · Fabio Estevam
Quoted 1 line · Fabio Estevam
Should we fix
spl_endlike this?Looking at u-boot-spl.map:
0x0000000000912264 0x0 common/spl/spl.o 0x0000000000912264 . = ALIGN (0x4) 0x0000000000912264 __image_copy_end = ..end
*(.__end)0x0000000000912264 _image_binary_end = .
__image_copy_endis the last address of the SPL inside the internal RAM.So shouldn't we do this instead?
common/spl/spl_legacy.c line 23
Quoted 6 lines
common/spl/spl_legacy.c +1
-1@@ -19,9 +19,17 @@static void spl_parse_legacy_validate (uintptr_t start,uintptr_t size) {uintptr_t spl_start = (uintptr_t )_start; -uintptr_t spl_end = (uintptr_t )__bss_end; +uintptr_t spl_end = (uintptr_t )__image_copy_end;uintptr_t end = start + size;
I think this breaks x86, without updating their linker scripts at least.
Signature · 1 line
Tom
Fabio Estevam
reviewerQuoted 1 line · Tom Rini
I think this breaks x86, without updating their linker scripts at least.
What about this instead?
common/spl/spl_legacy.c +1 -1
@@ -19,7 +19,7 @@static void spl_parse_legacy_validate (uintptr_t start,uintptr_t size) {uintptr_t spl_start = (uintptr_t )_start; -uintptr_t spl_end = (uintptr_t )__bss_end; +uintptr_t spl_end = (uintptr_t )_image_binary_end;uintptr_t end = start + size;
Short update on this regression.
Quoted 4 lines · Francesco Dolcini
I also noticed something weird on a colibri imx7s, this is not using SPL, likely something completly different, however given this is new also from rc5 I thought it's valuable to report:
Quoted 8 lines
``` U-Boot 2023.07-rc5-0.0.0-devel+git.580eb31199be (Jun 27 2023 - 13:39:58 +0000) CPU: Freescale i.MX7S rev1.2 800 MHz (running at 792 MHz) CPU: Extended Commercial temperature grade (-20C to 105C) at 30C Reset cause: POR DRAM: initcall sequence 8786eafc failed at call 8781b351 (err=-3) ### ERROR ### Please RESET the board ### ```
This is unrelated to v2023.07-rc5, the issue was introduced with 8c103c33fb14 ("dm: dts: Convert driver model tags to use new schema"), that is in since v2023.07-rc1.
Sorry about the initial incomplete/wrong information.
For some reason this affects only imx7s, while imx7d is fine (single core, only one USB host interface, while the dual variant seems just fine).
Not many ideas for the moment, we might as well be doing something plain wrong in our board file.
I quickly tried removing the whole &lcdif and it does not seems to help. I do not think we even enable display output support at the moment.
Francesco
Quoted 13 lines · Francesco Dolcini
Short update on this regression.
Quoted 10 lines · Francesco Dolcini
I also noticed something weird on a colibri imx7s, this is not using SPL, likely something completly different, however given this is new also from rc5 I thought it's valuable to report:
```
U-Boot 2023.07-rc5-0.0.0-devel+git.580eb31199be (Jun 27 2023 - 13:39:58 +0000)CPU: Freescale i.MX7S rev1.2 800 MHz (running at 792 MHz) CPU: Extended Commercial temperature grade (-20C to 105C) at 30C Reset cause: POR DRAM: initcall sequence 8786eafc failed at call 8781b351 (err=-3)
If you have the u-boot (elf file, unstripped), then check which initcall it is that failed . Just run arm-...-objdump -lSD on it and search for the 8781b350: address ; remember to clear the LSbit of the address in case this is thumb mode of the CPU.
Quoted 15 lines · Marek Vasut
Quoted 13 lines · Francesco Dolcini
Short update on this regression.
Quoted 10 lines · Francesco Dolcini
I also noticed something weird on a colibri imx7s, this is not using SPL, likely something completly different, however given this is new also from rc5 I thought it's valuable to report:
```
U-Boot 2023.07-rc5-0.0.0-devel+git.580eb31199be (Jun 27 2023 - 13:39:58 +0000)CPU: Freescale i.MX7S rev1.2 800 MHz (running at 792 MHz) CPU: Extended Commercial temperature grade (-20C to 105C) at 30C Reset cause: POR DRAM: initcall sequence 8786eafc failed at call 8781b351 (err=-3)
Quoted 4 lines
If you have the u-boot (elf file, unstripped), then check which initcall it is that failed . Just run arm-...-objdump -lSD on it and search for the
8781b350: address ; remember to clear the LSbit of the address in case this is thumb mode of the CPU.
U-Boot 2023.07-rc6 (Jul 03 2023 - 21:50:58 +0200)
CPU: Freescale i.MX7S rev1.2 800 MHz (running at 792 MHz) CPU: Extended Commercial temperature grade (-20C to 105C) at 35C Reset cause: POR DRAM: initcall sequence 8786fb00 failed at call 8781b715 (err=-3)
### ERROR ### Please RESET the board ###
u-boot/common/board_f.c:523
}
8781b710: 2000 movs r0, #0
8781b712: bd08 pop {r3, pc}8781b714 <fix_fdt>:fix_fdt():u-boot/common/board_f.c:729
return board_fix_fdt((void *)gd->fdt_blob); 8781b714: f8d9 0068 ldr.w r0, [r9, #104] ; 0x68 8781b718: f7ea bafe b.w 87805d18 <board_fix_fdt>
Quoted 36 lines · Francesco Dolcini
Quoted 15 lines · Marek Vasut
Quoted 13 lines · Francesco Dolcini
Short update on this regression.
Quoted 10 lines · Francesco Dolcini
I also noticed something weird on a colibri imx7s, this is not using SPL, likely something completly different, however given this is new also from rc5 I thought it's valuable to report:
```
U-Boot 2023.07-rc5-0.0.0-devel+git.580eb31199be (Jun 27 2023 - 13:39:58 +0000)CPU: Freescale i.MX7S rev1.2 800 MHz (running at 792 MHz) CPU: Extended Commercial temperature grade (-20C to 105C) at 30C Reset cause: POR DRAM: initcall sequence 8786eafc failed at call 8781b351 (err=-3)Quoted 4 lines
If you have the u-boot (elf file, unstripped), then check which initcall it is that failed . Just run arm-...-objdump -lSD on it and search for the
8781b350: address ; remember to clear the LSbit of the address in case this is thumb mode of the CPU.U-Boot 2023.07-rc6 (Jul 03 2023 - 21:50:58 +0200)
CPU: Freescale i.MX7S rev1.2 800 MHz (running at 792 MHz) CPU: Extended Commercial temperature grade (-20C to 105C) at 35C Reset cause: POR DRAM: initcall sequence 8786fb00 failed at call 8781b715 (err=-3)### ERROR ### Please RESET the board ###
u-boot/common/board_f.c:523
}8781b710: 2000 movs r0, #0 8781b712: bd08 pop {r3, pc}
Quoted 6 lines
8781b714<fix_fdt>:fix_fdt():u-boot/common/board_f.c:729return board_fix_fdt((void *)gd->fdt_blob); 8781b714: f8d9 0068 ldr.w r0, [r9, #104] ; 0x68 8781b718: f7ea bafe b.w 87805d18 <board_fix_fdt>
so, this seems to be the broken code:
/* i.MX 7Solo has only one single USB OTG1 but no USB host port */
if (is_cpu_type(MXC_CPU_MX7S)) {
int offset = fdt_path_offset(rw_fdt_blob, "/soc/bus@30800000/usb@30b20000");
return fdt_status_disabled(rw_fdt_blob, offset);
}now I wonder how is this related to that other change ...
Quoted 36 lines · Francesco Dolcini
Quoted 15 lines · Marek Vasut
Quoted 13 lines · Francesco Dolcini
Short update on this regression.
Quoted 10 lines · Francesco Dolcini
I also noticed something weird on a colibri imx7s, this is not using SPL, likely something completly different, however given this is new also from rc5 I thought it's valuable to report:
```
U-Boot 2023.07-rc5-0.0.0-devel+git.580eb31199be (Jun 27 2023 - 13:39:58 +0000)CPU: Freescale i.MX7S rev1.2 800 MHz (running at 792 MHz) CPU: Extended Commercial temperature grade (-20C to 105C) at 30C Reset cause: POR DRAM: initcall sequence 8786eafc failed at call 8781b351 (err=-3)Quoted 4 lines
If you have the u-boot (elf file, unstripped), then check which initcall it is that failed . Just run arm-...-objdump -lSD on it and search for the
8781b350: address ; remember to clear the LSbit of the address in case this is thumb mode of the CPU.U-Boot 2023.07-rc6 (Jul 03 2023 - 21:50:58 +0200)
CPU: Freescale i.MX7S rev1.2 800 MHz (running at 792 MHz) CPU: Extended Commercial temperature grade (-20C to 105C) at 35C Reset cause: POR DRAM: initcall sequence 8786fb00 failed at call 8781b715 (err=-3)### ERROR ### Please RESET the board ###
u-boot/common/board_f.c:523
}8781b710: 2000 movs r0, #0 8781b712: bd08 pop {r3, pc}
Quoted 6 lines
8781b714<fix_fdt>:fix_fdt():u-boot/common/board_f.c:729return board_fix_fdt((void *)gd->fdt_blob); 8781b714: f8d9 0068 ldr.w r0, [r9, #104] ; 0x68 8781b718: f7ea bafe b.w 87805d18 <board_fix_fdt>
So, that's in your board code then:
board/toradex/colibri_imx7/colibri_imx7.c:int board_fix_fdt(void *rw_fdt_blob)
Signature · 1 line
Tom
Quoted 44 lines · Tom Rini
Quoted 36 lines · Francesco Dolcini
Quoted 15 lines · Marek Vasut
Quoted 13 lines · Francesco Dolcini
Short update on this regression.
Quoted 10 lines · Francesco Dolcini
I also noticed something weird on a colibri imx7s, this is not using SPL, likely something completly different, however given this is new also from rc5 I thought it's valuable to report:
```
U-Boot 2023.07-rc5-0.0.0-devel+git.580eb31199be (Jun 27 2023 - 13:39:58 +0000)CPU: Freescale i.MX7S rev1.2 800 MHz (running at 792 MHz) CPU: Extended Commercial temperature grade (-20C to 105C) at 30C Reset cause: POR DRAM: initcall sequence 8786eafc failed at call 8781b351 (err=-3)Quoted 4 lines
If you have the u-boot (elf file, unstripped), then check which initcall it is that failed . Just run arm-...-objdump -lSD on it and search for the
8781b350: address ; remember to clear the LSbit of the address in case this is thumb mode of the CPU.U-Boot 2023.07-rc6 (Jul 03 2023 - 21:50:58 +0200)
CPU: Freescale i.MX7S rev1.2 800 MHz (running at 792 MHz) CPU: Extended Commercial temperature grade (-20C to 105C) at 35C Reset cause: POR DRAM: initcall sequence 8786fb00 failed at call 8781b715 (err=-3)### ERROR ### Please RESET the board ###
u-boot/common/board_f.c:523
}8781b710: 2000 movs r0, #0 8781b712: bd08 pop {r3, pc}Quoted 6 lines
8781b714<fix_fdt>:fix_fdt():u-boot/common/board_f.c:729return board_fix_fdt((void *)gd->fdt_blob); 8781b714: f8d9 0068 ldr.w r0, [r9, #104] ; 0x68 8781b718: f7ea bafe b.w 87805d18 <board_fix_fdt>
Quoted 2 lines
So, that's in your board code then:
board/toradex/colibri_imx7/colibri_imx7.c:intboard_fix_fdt(void *rw_fdt_blob)
Yep, this is the problematic code:
board/toradex/colibri_imx7/colibri_imx7.c:
int board_fix_fdt(void *rw_fdt_blob)
{
/* i.MX 7Solo has only one single USB OTG1 but no USB host port */
if (is_cpu_type(MXC_CPU_MX7S)) {
int offset = fdt_path_offset(rw_fdt_blob, "/soc/bus@30800000/usb@30b20000");
return fdt_status_disabled(rw_fdt_blob, offset);
}
return 0;
}For what is worth in this node "/soc/bus@30800000/usb@30b20000" the status="ok" property is already present.
Before 8c103c33fb14 ("dm: dts: Convert driver model tags to use new schema") fdt_status_disabled() did return 0, so all good no issue.
If I do this small partial revert
arch/arm/dts/imx7d-colibri-eval-v3-u-boot.dtsi +1 -1
@@ -15,7 +15,8 @@ pinctrl-0 = <&pinctrl_lcdif_dat &pinctrl_lcdif_ctrl>; display = <&display0>; - u-boot,dm-pre-reloc; + bootph-all;
fdt_status_disabled() returns 0 again.
With the current master, fdt_status_disabled() returns -3, -FDT_ERR_NOSPACE, and I assume I could just change my code to call fdt_increase_size() and call it done.
However, what the reason for this different behavior triggered by that change in the *-u-boot.dtsi ? Is this expected?
From a quick check multiple place in the code just disable/enable nodes or set properties without taking care of this, are those going to be affected by that commit that created the regression? Are those all buggy?
$ git grep fdt_setprop |wc -l 461
We have some helper around, for example arch/arm/mach-imx/imx8/fdt.c:disable_fdt_node(), but this is for example just specific on that file.
Simon: any suggestion?
Thanks,
Francesco
Fabio Estevam
reviewerHi Francesco,
arch/arm/dts/imx7d-colibri-eval-v3-u-boot.dtsi line 18
Quoted 10 lines · Francesco Dolcini
If I do this small partial revert
arch/arm/dts/imx7d-colibri-eval-v3-u-boot.dtsi +1
-1@@ -15,7 +15,8 @@ pinctrl-0 = <&pinctrl_lcdif_dat &pinctrl_lcdif_ctrl>; display = <&display0>; - u-boot,dm-pre-reloc; + bootph-all;
I managed to reproduce the behavior on a imx7d-sabresd by doing:
board/freescale/mx7dsabresd/mx7dsabresd.c +6 -0
@@ -25,6 +25,7 @@#include <i2c.h> #include <asm/mach-imx/mxc_i2c.h> #include <asm/arch/crm_regs.h> +#include <fdt_support.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -289,6 +290,20 @@ int power_init_board(void) }#endif +int board_fix_fdt (void *rw_fdt_blob) +{ +int ret; + + int offset = fdt_path_offset(rw_fdt_blob,
"/soc/bus@30800000/usb@30b20000");
+
+ ret = fdt_status_disabled(rw_fdt_blob, offset);
+
+ printf("******** offset is 0x%x\n", offset);
+ printf("******** ret is %d\n", ret);
+
+ return 0;
+}
+
int board_late_init(void)
configs/mx7dsabresd_defconfig +1 -0
@@ -86,3 +86,4 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5 CONFIG_CI_UDC=y CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_ERRNO_STR=y +CONFIG_OF_BOARD_FIXUP=y
With top of tree U-Boot it fails with:
******** offset is 0x7ba4
******** ret is -3
If u-boot.dtsi gets smaller, for example, by reverting 0aea5dda2928 then it succeeds:
******** offset is 0x7988
******** ret is 0
Quoted 14 lines
fdt_status_disabled()returns 0 again.With the current master,
fdt_status_disabled()returns -3, -FDT_ERR_NOSPACE, and I assume I could just change my code to callfdt_increase_size()and call it done.However, what the reason for this different behavior triggered by that change in the *-u-boot.dtsi ? Is this expected?
From a quick check multiple place in the code just disable/enable nodes or set properties without taking care of this, are those going to be affected by that commit that created the regression? Are those all buggy?
Quoted 6 lines
$ git grep fdt_setprop |wc -l 461We have some helper around, for example arch/arm/mach-imx/imx8/fdt.c:disable_fdt_node(), but this is for example just specific on that file.
Here is my suggestion: let's increase the fdt size locally on your board for now, just like turris_omnia.c:
board/toradex/colibri_imx7/colibri_imx7.c +0 -0
@@ -315,6 +315,15 @@ int board_fix_fdt(void *rw_fdt_blob)if (is_cpu_type (MXC_CPU_MX7S )) { int offset = fdt_path_offset(rw_fdt_blob,
"/soc/bus@30800000/usb@30b20000");
+ /*
+ * We're either adding status = "disabled" property, or changing + * status = "okay" to status = "disabled". In both cases we'll need more + * space. Increase the size a little. + */
+ if (fdt_increase_size(rw_fdt_blob, 32) < 0) {
+ printf("Cannot increase FDT size.\n");
+ return -ENOMEM;
+ }
return fdt_status_disabled(rw_fdt_blob, offset);
}Then for the next cycle, we should plan on adding this fdt_increase_size() into the common fdt_status_disabled().
Does it work?
Quoted 110 lines · Fabio Estevam
Hi Francesco,
arch/arm/dts/imx7d-colibri-eval-v3-u-boot.dtsi line 18
Quoted 10 lines · Francesco Dolcini
If I do this small partial revert
arch/arm/dts/imx7d-colibri-eval-v3-u-boot.dtsi +1
-1@@ -15,7 +15,8 @@ pinctrl-0 = <&pinctrl_lcdif_dat &pinctrl_lcdif_ctrl>; display = <&display0>; - u-boot,dm-pre-reloc; + bootph-all;I managed to reproduce the behavior on a imx7d-sabresd by doing:
board/freescale/mx7dsabresd/mx7dsabresd.c +15
-0@@ -25,6 +25,7 @@#include <i2c.h> #include <asm/mach-imx/mxc_i2c.h> #include <asm/arch/crm_regs.h> +#include <fdt_support.h> DECLARE_GLOBAL_DATA_PTR ;@@ -289,6 +290,20 @@ int power_init_board(void) }#endif +int board_fix_fdt (void *rw_fdt_blob) +{ +int ret; + +int offset =fdt_path_offset (rw_fdt_blob,"/soc/bus@30800000/usb@30b20000" ); + + ret =fdt_status_disabled (rw_fdt_blob, offset); + +printf ("******** offset is 0x%x\n" , offset); +printf ("******** ret is %d\n" , ret); + +return 0 ; +} +int board_late_init (void )configs/mx7dsabresd_defconfig +1
-0@@ -86,3 +86,4 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5 CONFIG_CI_UDC=y CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_ERRNO_STR=y +CONFIG_OF_BOARD_FIXUP=yWith top of tree U-Boot it fails with:
******** offset is
0x7ba4
******** ret is -3If
u-boot.dtsigets smaller, for example, by reverting0aea5dda2928then it succeeds:******** offset is
0x7988
******** ret is 0Quoted 14 lines
fdt_status_disabled()returns 0 again.With the current master,
fdt_status_disabled()returns -3, -FDT_ERR_NOSPACE, and I assume I could just change my code to callfdt_increase_size()and call it done.However, what the reason for this different behavior triggered by that change in the *-u-boot.dtsi ? Is this expected?
From a quick check multiple place in the code just disable/enable nodes or set properties without taking care of this, are those going to be affected by that commit that created the regression? Are those all buggy?
Quoted 6 lines
$ git grep fdt_setprop |wc -l 461We have some helper around, for example arch/arm/mach-imx/imx8/fdt.c:disable_fdt_node(), but this is for example just specific on that file.
Here is my suggestion: let's increase the fdt size locally on your board for now, just like
turris_omnia.c:board/toradex/colibri_imx7/colibri_imx7.c +9
-0@@ -315,6 +315,15 @@ int board_fix_fdt(void *rw_fdt_blob)if (is_cpu_type (MXC_CPU_MX7S )) {int offset =fdt_path_offset (rw_fdt_blob,"/soc/bus@30800000/usb@30b20000" ); +/* +* We're either adding status = "disabled" property, or changing +* status = "okay" to status = "disabled". In both cases we'll need more +* space. Increase the size a little. +*/ +if (fdt_increase_size (rw_fdt_blob,32 ) <0 ) { +printf ("Cannot increase FDT size.\n" ); +return -ENOMEM ; + }return fdt_status_disabled (rw_fdt_blob, offset); }
Quoted 2 lines
Then for the next cycle, we should plan on adding this
fdt_increase_size()into the commonfdt_status_disabled().
I'm a little leary of generic changes here having an unexpected size / performance impact. The API specifically does not "just" handle this case like it does for some others. We should update the docs around fdt_set_node_status and fdt_status_disabled to reference the return codes of fdt_setprop_string itself and check for anyone else that hasn't been considering this possible failure case.
Signature · 1 line
Tom
Quoted 10 lines · Tom Rini
Quoted 2 lines · Fabio Estevam
Then for the next cycle, we should plan on adding this
fdt_increase_size()into the commonfdt_status_disabled().I'm a little leary of generic changes here having an unexpected size / performance impact. The API specifically does not "just" handle this case like it does for some others. We should update the docs around
fdt_set_node_statusandfdt_status_disabledto reference the return codes offdt_setprop_stringitself and check for anyone else that hasn't been considering this possible failure case.
Maybe we can just add a new additional small wrapper that does the fdt_increase_size() if required? This is a generic need, not something every board should implement on its own.
Francesco
Quoted 4 lines · Fabio Estevam
Then for the next cycle, we should plan on adding this
fdt_increase_size()into the commonfdt_status_disabled().Does it work?
Now that the situation is pretty much clear I am not overly concerned for colibri-imx7s.
Do we consider this something to be worried about for other boards?
Francesco
Quoted 10 lines · Francesco Dolcini
Quoted 4 lines · Fabio Estevam
Then for the next cycle, we should plan on adding this
fdt_increase_size()into the commonfdt_status_disabled().Does it work?
Now that the situation is pretty much clear I am not overly concerned for colibri-imx7s.
Do we consider this something to be worried about for other boards?
The cases calling fdt_status_disabled itself are small enough that I think a quick audit isn't unreasonable (and PowerPC should probably mirror the kernel and pass -p 0x1000 in DTC_FLAGS so it becomes a non-issue).
Signature · 1 line
Tom
Quoted 10 lines · Tom Rini
Quoted 9 lines · Francesco Dolcini
Quoted 4 lines · Fabio Estevam
Then for the next cycle, we should plan on adding this
fdt_increase_size()into the commonfdt_status_disabled().Does it work?
Now that the situation is pretty much clear I am not overly concerned for colibri-imx7s.
Quoted 6 lines
Quoted 1 line
Do we consider this something to be worried about for other boards?
The cases calling
fdt_status_disableditself are small enough that I think a quick audit isn't unreasonable (and PowerPC should probably mirror the kernel and pass -p0x1000inDTC_FLAGSso it becomes a non-issue).
Do we expect this to not affect fdt_setprop() or other fdt_*() APIs? fdt_increase_size() seems not to be used most of the time, unless I am missing something here.
Francesco
Quoted 13 lines · Francesco Dolcini
Quoted 12 lines · Tom Rini
Quoted 10 lines · Francesco Dolcini
Quoted 4 lines · Fabio Estevam
Then for the next cycle, we should plan on adding this
fdt_increase_size()into the commonfdt_status_disabled().Does it work?
Now that the situation is pretty much clear I am not overly concerned for colibri-imx7s.
Do we consider this something to be worried about for other boards?
Quoted 8 lines
Quoted 4 lines
The cases calling
fdt_status_disableditself are small enough that I think a quick audit isn't unreasonable (and PowerPC should probably mirror the kernel and pass -p0x1000inDTC_FLAGSso it becomes a non-issue).Do we expect this to not affect
fdt_setprop()or other fdt_*() APIs?fdt_increase_size()seems not to be used most of the time, unless I am missing something here.
It depends on the case. For example, fdt_node_set_part_info is big/complex enough that it does call fdt_increase_size (which is not cheap) when there's no space. Other cases already do check for no space and grow+retry. And then the general answer is that if you're expecting needing to make "big" changes to the dtb you should pad it to start with as that's a free operation at run time.
Signature · 1 line
Tom
Fabio Estevam
reviewerQuoted 4 lines · Francesco Dolcini
Now that the situation is pretty much clear I am not overly concerned for colibri-imx7s.
Do we consider this something to be worried about for other boards?
There are only three boards that check the return value from fdt_status_disabled():
- board/toradex/colibri_imx7/colibri_imx7.c
- board/gdsys/a38x/dt_helpers.c
- board/CZ.NIC/turris_omnia/turris_omnia.c
As of today, only turris_omnia calls the fdt_increase_size() prior to fdt_status_disabled().
Quoted 8 lines · Fabio Estevam
Quoted 4 lines · Francesco Dolcini
Now that the situation is pretty much clear I am not overly concerned for colibri-imx7s.
Do we consider this something to be worried about for other boards?
There are only three boards that check the return value from
The boards that do not check the return value might start to behave wrongly without an obvious error to help the debugging.
Francesco
Quoted 2 lines · Francesco Dolcini
The boards that do not check the return value might start to behave wrongly without an obvious error to help the debugging.
Yes, the current implementation of fdt_status_disabled() is fragile, but there's not so much we can do for the upcoming 2023.07.
I can try to prepare a patch to improve it after 2023.07 is out next week.
Quoted 9 lines · Fabio Estevam
Quoted 2 lines · Francesco Dolcini
The boards that do not check the return value might start to behave wrongly without an obvious error to help the debugging.
Yes, the current implementation of
fdt_status_disabled()is fragile, but there's not so much we can do for the upcoming 2023.07.I can try to prepare a patch to improve it after 2023.07 is out next week.
It's also been fragile-as-designed since inception. The trigger here was that renaming a ton of properties _reduced_ the overall dtb size itself and so some edge cases got pushed over the edge. I'm honestly not sure if it's better to:
- Give everyone a small padding by default
- Make the platforms which may call one of these functions a small padding by default
- Audit the callers and make them handle -FDT_ERR_NOSPACE like the other cases where we grow the dtb size do. Even if yes, many of those other cases are for non-trivial growth rather than just adding 4 more letters.
- Make fdt_set_node_status() handle the disabled case when out of space and grow/retry.
Signature · 1 line
Tom
Hi,
Quoted 12 lines · Tom Rini
Quoted 9 lines · Fabio Estevam
Quoted 2 lines · Francesco Dolcini
The boards that do not check the return value might start to behave wrongly without an obvious error to help the debugging.
Yes, the current implementation of
fdt_status_disabled()is fragile, but there's not so much we can do for the upcoming 2023.07.I can try to prepare a patch to improve it after 2023.07 is out next week.
Quoted 7 lines
It's also been fragile-as-designed since inception. The trigger here was that renaming a ton of properties _reduced_ the overall dtb size itself and so some edge cases got pushed over the edge. I'm honestly not sure if it's better to:
- Give everyone a small padding by default
- Make the platforms which may call one of these functions a small padding by default
One of the above seems good to me. Perhaps we could add a default padding, with the ability to reduce it to 0, or increase it. I suspect that not many boards update the FDT in SPL.
Quoted 6 lines
- Audit the callers and make them handle -FDT_ERR_NOSPACE like the other cases where we grow the dtb size do. Even if yes, many of those other cases are for non-trivial growth rather than just adding 4 more letters.
- Makefdt_set_node_status()handle the disabled case when out of space and grow/retry.
I don't like that since:
- it adds to complexity in that a 'leaf' function is messing with stuff it shouldn't
- In generate we don't know if there is space to increase the FDT size
- It likely increase code size for a case that cannot happen if people have tested it properly
- It affects all boards
If boards are ignoring errors, that is up to the boards. We do encourage people (in core review) to check all errors. This is an example of why.
Regards,
Simon