diff mbox series

arm64: versal: Do not place u-boot to reserved memory location

Message ID 15426fa6d64835dd23c5c8c12bbfc97306fb6098.1647527129.git.michal.simek@xilinx.com
State Accepted
Commit f66d0b53462cdd209ec045c8dcf623046fa4f3cc
Delegated to: Michal Simek
Headers show
Series arm64: versal: Do not place u-boot to reserved memory location | expand

Commit Message

Michal Simek March 17, 2022, 2:25 p.m. UTC
Versal can also have reserved space in DT which u-boot has to avoid to
placing self to that location. The same change was done in ZynqMP by commit
ce39ee28ec31 ("zynqmp: Do not place u-boot to reserved memory location")
and also for microblaze by commit d7b5cc89d329 ("microblaze: Do not place
u-boot to reserved memory location").

The patch was tested by adding reserved-memory node to DT and check via
bdinfo back.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 board/xilinx/versal/board.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

Michal Simek March 29, 2022, 7:16 a.m. UTC | #1
čt 17. 3. 2022 v 15:25 odesílatel Michal Simek <michal.simek@xilinx.com> napsal:
>
> Versal can also have reserved space in DT which u-boot has to avoid to
> placing self to that location. The same change was done in ZynqMP by commit
> ce39ee28ec31 ("zynqmp: Do not place u-boot to reserved memory location")
> and also for microblaze by commit d7b5cc89d329 ("microblaze: Do not place
> u-boot to reserved memory location").
>
> The patch was tested by adding reserved-memory node to DT and check via
> bdinfo back.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
>  board/xilinx/versal/board.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
>
> diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c
> index 299e128f7b9d..9940f2aeb337 100644
> --- a/board/xilinx/versal/board.c
> +++ b/board/xilinx/versal/board.c
> @@ -9,6 +9,7 @@
>  #include <env.h>
>  #include <fdtdec.h>
>  #include <init.h>
> +#include <image.h>
>  #include <env_internal.h>
>  #include <log.h>
>  #include <malloc.h>
> @@ -249,6 +250,25 @@ int dram_init(void)
>         return 0;
>  }
>
> +ulong board_get_usable_ram_top(ulong total_size)
> +{
> +       phys_size_t size;
> +       phys_addr_t reg;
> +       struct lmb lmb;
> +
> +       /* found enough not-reserved memory to relocated U-Boot */
> +       lmb_init(&lmb);
> +       lmb_add(&lmb, gd->ram_base, gd->ram_size);
> +       boot_fdt_add_mem_rsv_regions(&lmb, (void *)gd->fdt_blob);
> +       size = ALIGN(CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE);
> +       reg = lmb_alloc(&lmb, size, MMU_SECTION_SIZE);
> +
> +       if (!reg)
> +               reg = gd->ram_top - size;
> +
> +       return reg + size;
> +}
> +
>  void reset_cpu(void)
>  {
>  }
> --
> 2.35.1
>

Applied.
M
diff mbox series

Patch

diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c
index 299e128f7b9d..9940f2aeb337 100644
--- a/board/xilinx/versal/board.c
+++ b/board/xilinx/versal/board.c
@@ -9,6 +9,7 @@ 
 #include <env.h>
 #include <fdtdec.h>
 #include <init.h>
+#include <image.h>
 #include <env_internal.h>
 #include <log.h>
 #include <malloc.h>
@@ -249,6 +250,25 @@  int dram_init(void)
 	return 0;
 }
 
+ulong board_get_usable_ram_top(ulong total_size)
+{
+	phys_size_t size;
+	phys_addr_t reg;
+	struct lmb lmb;
+
+	/* found enough not-reserved memory to relocated U-Boot */
+	lmb_init(&lmb);
+	lmb_add(&lmb, gd->ram_base, gd->ram_size);
+	boot_fdt_add_mem_rsv_regions(&lmb, (void *)gd->fdt_blob);
+	size = ALIGN(CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE);
+	reg = lmb_alloc(&lmb, size, MMU_SECTION_SIZE);
+
+	if (!reg)
+		reg = gd->ram_top - size;
+
+	return reg + size;
+}
+
 void reset_cpu(void)
 {
 }