All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: imx: imx8m: Fix board_get_usable_ram_top()
@ 2022-04-14 13:51 Marek Vasut
  2022-04-14 14:46 ` Fabio Estevam
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Marek Vasut @ 2022-04-14 13:51 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Fabio Estevam, Frieder Schrempf, Peng Fan, Stefano Babic

The 4 GiB boundary is at 0xffffffff+1 , not at 0x80000000, fix this.

The PHYS_SDRAM of i.MX8M is at 0x40000000 , so to restrict ram_top
below 4 GiB, the ram_top has to be set to 0xffffffff as it is not
an offset from the start of PHYS_SDRAM, but rather a physical address
marking the topmost allowed DRAM address.

Fixes: e27bddff4b9 ("imx8m: Restrict usable memory to space below 4G boundary")
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <festevam@denx.de>
Cc: Frieder Schrempf <frieder.schrempf@kontron.de>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Stefano Babic <sbabic@denx.de>
---
 arch/arm/mach-imx/imx8m/soc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
index 8171631db10..e7fe7c2fd88 100644
--- a/arch/arm/mach-imx/imx8m/soc.c
+++ b/arch/arm/mach-imx/imx8m/soc.c
@@ -331,7 +331,7 @@ phys_size_t get_effective_memsize(void)
 
 ulong board_get_usable_ram_top(ulong total_size)
 {
-	ulong top_addr = PHYS_SDRAM + gd->ram_size;
+	ulong top_addr;
 
 	/*
 	 * Some IPs have their accessible address space restricted by
@@ -339,8 +339,7 @@ ulong board_get_usable_ram_top(ulong total_size)
 	 * space below the 4G address boundary (which is 3GiB big),
 	 * even when the effective available memory is bigger.
 	 */
-	if (top_addr > 0x80000000)
-		top_addr = 0x80000000;
+	top_addr = clamp_val((u64)PHYS_SDRAM + gd->ram_size, 0, 0xffffffff);
 
 	/*
 	 * rom_pointer[0] stores the TEE memory start address.
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ARM: imx: imx8m: Fix board_get_usable_ram_top()
  2022-04-14 13:51 [PATCH] ARM: imx: imx8m: Fix board_get_usable_ram_top() Marek Vasut
@ 2022-04-14 14:46 ` Fabio Estevam
  2022-04-14 14:47 ` Frieder Schrempf
  2022-04-22  8:47 ` sbabic
  2 siblings, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2022-04-14 14:46 UTC (permalink / raw)
  To: Marek Vasut; +Cc: u-boot, Frieder Schrempf, Peng Fan, Stefano Babic

Hi Marek,

On 14/04/2022 10:51, Marek Vasut wrote:
> The 4 GiB boundary is at 0xffffffff+1 , not at 0x80000000, fix this.
> 
> The PHYS_SDRAM of i.MX8M is at 0x40000000 , so to restrict ram_top
> below 4 GiB, the ram_top has to be set to 0xffffffff as it is not
> an offset from the start of PHYS_SDRAM, but rather a physical address
> marking the topmost allowed DRAM address.
> 
> Fixes: e27bddff4b9 ("imx8m: Restrict usable memory to space below 4G 
> boundary")
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Fabio Estevam <festevam@denx.de>
> Cc: Frieder Schrempf <frieder.schrempf@kontron.de>
> Cc: Peng Fan <peng.fan@nxp.com>
> Cc: Stefano Babic <sbabic@denx.de>

Good catch!

Reviewed-by: Fabio Estevam <festevam@denx.de>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ARM: imx: imx8m: Fix board_get_usable_ram_top()
  2022-04-14 13:51 [PATCH] ARM: imx: imx8m: Fix board_get_usable_ram_top() Marek Vasut
  2022-04-14 14:46 ` Fabio Estevam
@ 2022-04-14 14:47 ` Frieder Schrempf
  2022-04-22  8:47 ` sbabic
  2 siblings, 0 replies; 4+ messages in thread
From: Frieder Schrempf @ 2022-04-14 14:47 UTC (permalink / raw)
  To: Marek Vasut, u-boot; +Cc: Fabio Estevam, Peng Fan, Stefano Babic

Am 14.04.22 um 15:51 schrieb Marek Vasut:
> The 4 GiB boundary is at 0xffffffff+1 , not at 0x80000000, fix this.
> 
> The PHYS_SDRAM of i.MX8M is at 0x40000000 , so to restrict ram_top
> below 4 GiB, the ram_top has to be set to 0xffffffff as it is not
> an offset from the start of PHYS_SDRAM, but rather a physical address
> marking the topmost allowed DRAM address.
> 
> Fixes: e27bddff4b9 ("imx8m: Restrict usable memory to space below 4G boundary")
> Signed-off-by: Marek Vasut <marex@denx.de>

Thanks for the fix!

Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>

> Cc: Fabio Estevam <festevam@denx.de>
> Cc: Frieder Schrempf <frieder.schrempf@kontron.de>
> Cc: Peng Fan <peng.fan@nxp.com>
> Cc: Stefano Babic <sbabic@denx.de>
> ---
>  arch/arm/mach-imx/imx8m/soc.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
> index 8171631db10..e7fe7c2fd88 100644
> --- a/arch/arm/mach-imx/imx8m/soc.c
> +++ b/arch/arm/mach-imx/imx8m/soc.c
> @@ -331,7 +331,7 @@ phys_size_t get_effective_memsize(void)
>  
>  ulong board_get_usable_ram_top(ulong total_size)
>  {
> -	ulong top_addr = PHYS_SDRAM + gd->ram_size;
> +	ulong top_addr;
>  
>  	/*
>  	 * Some IPs have their accessible address space restricted by
> @@ -339,8 +339,7 @@ ulong board_get_usable_ram_top(ulong total_size)
>  	 * space below the 4G address boundary (which is 3GiB big),
>  	 * even when the effective available memory is bigger.
>  	 */
> -	if (top_addr > 0x80000000)
> -		top_addr = 0x80000000;
> +	top_addr = clamp_val((u64)PHYS_SDRAM + gd->ram_size, 0, 0xffffffff);
>  
>  	/*
>  	 * rom_pointer[0] stores the TEE memory start address.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] ARM: imx: imx8m: Fix board_get_usable_ram_top()
  2022-04-14 13:51 [PATCH] ARM: imx: imx8m: Fix board_get_usable_ram_top() Marek Vasut
  2022-04-14 14:46 ` Fabio Estevam
  2022-04-14 14:47 ` Frieder Schrempf
@ 2022-04-22  8:47 ` sbabic
  2 siblings, 0 replies; 4+ messages in thread
From: sbabic @ 2022-04-22  8:47 UTC (permalink / raw)
  To: Marek Vasut, u-boot

> The 4 GiB boundary is at 0xffffffff+1 , not at 0x80000000, fix this.
> The PHYS_SDRAM of i.MX8M is at 0x40000000 , so to restrict ram_top
> below 4 GiB, the ram_top has to be set to 0xffffffff as it is not
> an offset from the start of PHYS_SDRAM, but rather a physical address
> marking the topmost allowed DRAM address.
> Fixes: e27bddff4b9 ("imx8m: Restrict usable memory to space below 4G boundary")
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Fabio Estevam <festevam@denx.de>
> Cc: Frieder Schrempf <frieder.schrempf@kontron.de>
> Cc: Peng Fan <peng.fan@nxp.com>
> Cc: Stefano Babic <sbabic@denx.de>
> Reviewed-by: Fabio Estevam <festevam@denx.de>
> Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-22  8:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-14 13:51 [PATCH] ARM: imx: imx8m: Fix board_get_usable_ram_top() Marek Vasut
2022-04-14 14:46 ` Fabio Estevam
2022-04-14 14:47 ` Frieder Schrempf
2022-04-22  8:47 ` sbabic

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.