diff mbox series

[U-Boot,v3,02/12] spl: fit: Make room in the FDT before applying overlays

Message ID 20190523103912.3790-3-jjhiblot@ti.com
State Superseded
Delegated to: Tom Rini
Headers show
Series Add support for applications of overlays in SPL | expand

Commit Message

Jean-Jacques Hiblot May 23, 2019, 10:39 a.m. UTC
Make room in the FDT before applying the overlay, otherwise it may fail if
the overlay is big. As the exact added size is not known in advance, just
add the size of the overlay.
Move after the end of the application of the overlays, the resize  of the
FDT for the injection of the details on the loadables.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---

Changes in v3: None
Changes in v2: None

 common/spl/spl_fit.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

Comments

Simon Glass June 22, 2019, 7:09 p.m. UTC | #1
On Thu, 23 May 2019 at 11:39, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>
> Make room in the FDT before applying the overlay, otherwise it may fail if
> the overlay is big. As the exact added size is not known in advance, just
> add the size of the overlay.
> Move after the end of the application of the overlays, the resize  of the
> FDT for the injection of the details on the loadables.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  common/spl/spl_fit.c | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 3fbcb969f8..c1c982f002 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -301,11 +301,6 @@  static int spl_fit_append_fdt(struct spl_image_info *spl_image,
 	/* Make the load-address of the FDT available for the SPL framework */
 	spl_image->fdt_addr = (void *)image_info.load_addr;
 #if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
-	/* Try to make space, so we can inject details on the loadables */
-	ret = fdt_shrink_to_minimum(spl_image->fdt_addr, 8192);
-	if (ret < 0)
-		return ret;
-#endif
 #if defined(CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY)
 	for (; ; index++) {
 		node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP, index);
@@ -319,6 +314,11 @@  static int spl_fit_append_fdt(struct spl_image_info *spl_image,
 		if (ret < 0)
 			return ret;
 
+		/* Make room in FDT for changes coming from the overlay */
+		ret = fdt_increase_size(spl_image->fdt_addr, image_info.size);
+		if (ret < 0)
+			return ret;
+
 		ret = fdt_overlay_apply_verbose(spl_image->fdt_addr,
 						(void *)image_info.load_addr);
 		if (ret)
@@ -328,6 +328,12 @@  static int spl_fit_append_fdt(struct spl_image_info *spl_image,
 		      fit_get_name(fit, node, NULL));
 	}
 #endif
+	/* Try to make space, so we can inject details on the loadables */
+	ret = fdt_shrink_to_minimum(spl_image->fdt_addr, 8192);
+	if (ret < 0)
+		return ret;
+#endif
+
 	return ret;
 }