diff mbox series

[v2,07/13] imx8mm_evk: adjust dram size in case bl32 is used

Message ID 20200327102825.10230-8-igor.opaniuk@gmail.com
State Accepted
Commit 47d430baed16b35a1afc5ae2ae8c468de8d21efd
Delegated to: Stefano Babic
Headers show
Series bugfix/improvements for IMX-based modules | expand

Commit Message

Igor Opaniuk March 27, 2020, 10:28 a.m. UTC
From: Igor Opaniuk <igor.opaniuk@toradex.com>

Adjust DRAM size in case BL32 secure payload is loaded (OP-TEE/Trusty),
so during MMU initialization U-Boot won't touch this mem area.

BL32 is loaded to the end of DRAM, bl32 payload size is read from
rom_pointer[1]. This relates to the issue described in
59efa6b52b("imx8m: Fix MMU table issue for OPTEE memory").

Signed-off-by: Igor Opaniuk <igor.opaniuk@toradex.com>
---

 board/freescale/imx8mm_evk/imx8mm_evk.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Oleksandr Suvorov March 27, 2020, 10:49 a.m. UTC | #1
On Fri, Mar 27, 2020 at 12:29 PM Igor Opaniuk <igor.opaniuk@gmail.com> wrote:
>
> From: Igor Opaniuk <igor.opaniuk@toradex.com>
>
> Adjust DRAM size in case BL32 secure payload is loaded (OP-TEE/Trusty),
> so during MMU initialization U-Boot won't touch this mem area.
>
> BL32 is loaded to the end of DRAM, bl32 payload size is read from
> rom_pointer[1]. This relates to the issue described in
> 59efa6b52b("imx8m: Fix MMU table issue for OPTEE memory").
>
> Signed-off-by: Igor Opaniuk <igor.opaniuk@toradex.com>

> ---
>
>  board/freescale/imx8mm_evk/imx8mm_evk.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/board/freescale/imx8mm_evk/imx8mm_evk.c b/board/freescale/imx8mm_evk/imx8mm_evk.c
> index c5fd940eeb..53ebb949df 100644
> --- a/board/freescale/imx8mm_evk/imx8mm_evk.c
> +++ b/board/freescale/imx8mm_evk/imx8mm_evk.c
> @@ -15,7 +15,11 @@ DECLARE_GLOBAL_DATA_PTR;
>
>  int dram_init(void)
>  {
> -       gd->ram_size = PHYS_SDRAM_SIZE;


> +       /* rom_pointer[1] contains the size of TEE occupies */
> +       if (rom_pointer[1])
> +               gd->ram_size = PHYS_SDRAM_SIZE - rom_pointer[1];
> +       else
> +               gd->ram_size = PHYS_SDRAM_SIZE;

Is not this code equivalent to just one line?
      gd->ram_size = PHYS_SDRAM_SIZE - rom_pointer[1];

If rom_pointer[1] == 0, so the gd->ram_size gets the PHYS_SDRAM_SIZE value.

>
>         return 0;
>  }
> --
> 2.17.1
>
Stefano Babic April 18, 2020, 10:50 a.m. UTC | #2
> From: Igor Opaniuk <igor.opaniuk@toradex.com>
> Adjust DRAM size in case BL32 secure payload is loaded (OP-TEE/Trusty),
> so during MMU initialization U-Boot won't touch this mem area.
> BL32 is loaded to the end of DRAM, bl32 payload size is read from
> rom_pointer[1]. This relates to the issue described in
> 59efa6b52b("imx8m: Fix MMU table issue for OPTEE memory").
> Signed-off-by: Igor Opaniuk <igor.opaniuk@toradex.com>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/board/freescale/imx8mm_evk/imx8mm_evk.c b/board/freescale/imx8mm_evk/imx8mm_evk.c
index c5fd940eeb..53ebb949df 100644
--- a/board/freescale/imx8mm_evk/imx8mm_evk.c
+++ b/board/freescale/imx8mm_evk/imx8mm_evk.c
@@ -15,7 +15,11 @@  DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
-	gd->ram_size = PHYS_SDRAM_SIZE;
+	/* rom_pointer[1] contains the size of TEE occupies */
+	if (rom_pointer[1])
+		gd->ram_size = PHYS_SDRAM_SIZE - rom_pointer[1];
+	else
+		gd->ram_size = PHYS_SDRAM_SIZE;
 
 	return 0;
 }