[U-Boot] [PATCH 9/9] mpc85xx: add casts for ram size in min() calculation.

York Sun york.sun at nxp.com
Thu Jul 26 16:12:24 UTC 2018


On 07/26/2018 07:00 AM, Philipp Tomsich wrote:
> With the change of the ram size fields to u64, we need to use explicit
> casts to ensure that min()-implementation sees the same type for both
> its arguments.
> 
> Signed-off-by: Philipp Tomsich <philipp.tomsich at theobroma-systems.com>
> ---
> 
>  arch/powerpc/cpu/mpc85xx/cpu.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/cpu/mpc85xx/cpu.c b/arch/powerpc/cpu/mpc85xx/cpu.c
> index bf48836..5664872 100644
> --- a/arch/powerpc/cpu/mpc85xx/cpu.c
> +++ b/arch/powerpc/cpu/mpc85xx/cpu.c
> @@ -604,7 +604,8 @@ static int reset_tlb(phys_addr_t p_addr, u32 size, phys_addr_t *phys_offset)
>  int arch_memory_test_advance(u32 *vstart, u32 *size, phys_addr_t *phys_offset)
>  {
>  	phys_addr_t test_cap, p_addr;
> -	phys_size_t p_size = min(gd->ram_size, CONFIG_MAX_MEM_MAPPED);
> +	phys_size_t p_size = min((phys_size_t)gd->ram_size,
> +				 (phys_size_t)CONFIG_MAX_MEM_MAPPED);
>  
>  #if !defined(CONFIG_PHYS_64BIT) || \
>      !defined(CONFIG_SYS_INIT_RAM_ADDR_PHYS) || \
> @@ -632,7 +633,8 @@ int arch_memory_test_advance(u32 *vstart, u32 *size, phys_addr_t *phys_offset)
>  /* initialization for testing area */
>  int arch_memory_test_prepare(u32 *vstart, u32 *size, phys_addr_t *phys_offset)
>  {
> -	phys_size_t p_size = min(gd->ram_size, CONFIG_MAX_MEM_MAPPED);
> +	phys_size_t p_size = min((phys_size_t)gd->ram_size,
> +				 (phys_size_t)CONFIG_MAX_MEM_MAPPED);
>  
>  	*vstart = CONFIG_SYS_DDR_SDRAM_BASE;
>  	*size = (u32) p_size;	/* CONFIG_MAX_MEM_MAPPED < 4G */
> 

We didn't have any issue with 36-bit physical address on mpc85xx. I see
this change is needed after you change gd->ram_size.

Reviewed-by: York Sun <york.sun at nxp.com>


More information about the U-Boot mailing list