airoha: rework RAM size handling to support multiple RAM size
Subsystems (2)
PATCH 1/1 airoha: rework RAM size handling to support multiple RAM size
There are multiple version of the same reference board with different RAM size and it's not enough to base the RAM size entirely from DT. To better support it use the get_ram_size way to scan for the actual RAM size of Airoha SoC and increase the size of the memory map.
--- arch/arm/mach-airoha/an7581/init.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
arch/arm/mach-airoha/an7581/init.c +19 -4
@@ -2,10 +2,14 @@#include <fdtdec.h> #include <init.h> +#include <linux/sizes.h> #include <sysreset.h> #include <asm/armv8/mmu.h> +#include <asm/global_data.h> #include <asm/system.h> +DECLARE_GLOBAL_DATA_PTR ; +int print_cpuinfo (void ) {printf ("CPU: Airoha AN7581\n" );
@@ -14,12 +18,23 @@ int print_cpuinfo(void)int dram_init (void ) { -return fdtdec_setup_mem_size_base (); +int ret; + + ret =fdtdec_setup_mem_size_base (); +if (ret) +return ret; + + gd->ram_size =get_ram_size ((void *)gd->ram_base,SZ_8G ); + +return 0 ; }int dram_init_banksize (void ) { -return fdtdec_setup_memory_banksize (); + gd->bd->bi_dram[0 ].start = gd->ram_base; + gd->bd->bi_dram[0 ].size = gd->ram_size; + +return 0 ; }void reset_cpu (void )
@@ -32,12 +47,12 @@ static struct mm_region an7581_mem_map[] = {/* DDR */ .virt = 0x80000000UL, .phys = 0x80000000UL, - .size = 0x80000000UL, + .size = 0x200000000ULL, .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE, }, { .virt = 0x00000000UL, .phys = 0x00000000UL, - .size =0x20000000UL , + .size =0x40000000UL , .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |PTE_BLOCK_NON_SHARE |PTE_BLOCK_PXN |PTE_BLOCK_UXN
Signature · 1 line
2.50.0
Quoted 31 lines · Christian Marangi
There are multiple version of the same reference board with different RAM size and it's not enough to base the RAM size entirely from DT. To better support it use the
get_ram_sizeway to scan for the actual RAM size of Airoha SoC and increase the size of the memory map.Signed-off-by Christian Marangi <[email protected]>--- arch/arm/mach-airoha/an7581/init.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)arch/arm/mach-airoha/an7581/init.c +4
-0@@ -2,10 +2,14 @@#include <fdtdec.h> #include <init.h> +#include <linux/sizes.h> #include <sysreset.h> #include <asm/armv8/mmu.h> +#include <asm/global_data.h> #include <asm/system.h> +DECLARE_GLOBAL_DATA_PTR ; +int print_cpuinfo (void ) {printf ("CPU: Airoha AN7581\n" );@@ -14,12 +18,23 @@ int print_cpuinfo(void)
arch/arm/mach-airoha/an7581/init.c int print_cpuinfo(void) · line 27
Quoted 10 lines
arch/arm/mach-airoha/an7581/init.c +7
-1int dram_init (void ) { -return fdtdec_setup_mem_size_base (); +int ret; + + ret =fdtdec_setup_mem_size_base (); +if (ret) +return ret; + + gd->ram_size =get_ram_size ((void *)gd->ram_base,SZ_8G );
Can we use a memory size passed by airoha trusted firmware instead of playing with get_ram_size()?
arch/arm/mach-airoha/an7581/init.c int print_cpuinfo(void) · line 35
Quoted 9 lines
arch/arm/mach-airoha/an7581/init.c +4
-1+ +return 0 ; }int dram_init_banksize (void ) { -return fdtdec_setup_memory_banksize (); + gd->bd->bi_dram[0 ].start = gd->ram_base; + gd->bd->bi_dram[0 ].size = gd->ram_size;
as I know u-boot can safely use only 2Gb of memory, thus it's better
#define CFG_MAX_MEM_MAPPED SZ_2G
and replace above line with
gd->bd->bi_dram[0].size = get_effective_memsize();
Quoted 20 lines
arch/arm/mach-airoha/an7581/init.c +4
-2+ +return 0 ; }void reset_cpu (void )@@ -32,12 +47,12 @@ static struct mm_region an7581_mem_map[] = {/* DDR */ .virt = 0x80000000UL, .phys = 0x80000000UL, - .size = 0x80000000UL, + .size = 0x200000000ULL, .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE, }, { .virt = 0x00000000UL, .phys = 0x00000000UL, - .size =0x20000000UL , + .size =0x40000000UL , .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |PTE_BLOCK_NON_SHARE |PTE_BLOCK_PXN |PTE_BLOCK_UXN
Quoted 33 lines · Mikhail Kshevetskiy
Quoted 31 lines · Christian Marangi
There are multiple version of the same reference board with different RAM size and it's not enough to base the RAM size entirely from DT. To better support it use the
get_ram_sizeway to scan for the actual RAM size of Airoha SoC and increase the size of the memory map.Signed-off-by Christian Marangi <[email protected]>--- arch/arm/mach-airoha/an7581/init.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)arch/arm/mach-airoha/an7581/init.c +4
-0@@ -2,10 +2,14 @@#include <fdtdec.h> #include <init.h> +#include <linux/sizes.h> #include <sysreset.h> #include <asm/armv8/mmu.h> +#include <asm/global_data.h> #include <asm/system.h> +DECLARE_GLOBAL_DATA_PTR ; +int print_cpuinfo (void ) {printf ("CPU: Airoha AN7581\n" );@@ -14,12 +18,23 @@ int print_cpuinfo(void)
Quoted 14 lines
arch/arm/mach-airoha/an7581/init.c int print_cpuinfo(void) · line 27
Quoted 10 lines
arch/arm/mach-airoha/an7581/init.c +7
-1int dram_init (void ) { -return fdtdec_setup_mem_size_base (); +int ret; + + ret =fdtdec_setup_mem_size_base (); +if (ret) +return ret; + + gd->ram_size =get_ram_size ((void *)gd->ram_base,SZ_8G );Can we use a memory size passed by airoha trusted firmware instead of playing with
get_ram_size()?
Hi I received some feedback from Airoha about this and sadly it's not possible. There are too much version of ATF and only some of them provide RAM size in some way or another. Also there isn't an exact HW trap to read to know the RAM size hence raw testing the ram and not depending externally is the only solution :(
I will address all the other comments.
Quoted 37 lines
arch/arm/mach-airoha/an7581/init.c int print_cpuinfo(void) · line 35
Quoted 9 lines
arch/arm/mach-airoha/an7581/init.c +4
-1+ +return 0 ; }int dram_init_banksize (void ) { -return fdtdec_setup_memory_banksize (); + gd->bd->bi_dram[0 ].start = gd->ram_base; + gd->bd->bi_dram[0 ].size = gd->ram_size;as I know u-boot can safely use only 2Gb of memory, thus it's better
#define CFG_MAX_MEM_MAPPED
SZ_2Gand replace above line with
gd->bd->bi_dram[0].size =
get_effective_memsize();Quoted 20 lines
arch/arm/mach-airoha/an7581/init.c +4
-2+ +return 0 ; }void reset_cpu (void )@@ -32,12 +47,12 @@ static struct mm_region an7581_mem_map[] = {/* DDR */ .virt = 0x80000000UL, .phys = 0x80000000UL, - .size = 0x80000000UL, + .size = 0x200000000ULL, .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE, }, { .virt = 0x00000000UL, .phys = 0x00000000UL, - .size =0x20000000UL , + .size =0x40000000UL , .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |PTE_BLOCK_NON_SHARE |PTE_BLOCK_PXN |PTE_BLOCK_UXN
Signature · 1 line
Ansuel
Quoted 46 lines · Christian Marangi
Quoted 32 lines · Mikhail Kshevetskiy
Quoted 31 lines · Christian Marangi
There are multiple version of the same reference board with different RAM size and it's not enough to base the RAM size entirely from DT. To better support it use the
get_ram_sizeway to scan for the actual RAM size of Airoha SoC and increase the size of the memory map.Signed-off-by Christian Marangi <[email protected]>--- arch/arm/mach-airoha/an7581/init.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)arch/arm/mach-airoha/an7581/init.c +4
-0@@ -2,10 +2,14 @@#include <fdtdec.h> #include <init.h> +#include <linux/sizes.h> #include <sysreset.h> #include <asm/armv8/mmu.h> +#include <asm/global_data.h> #include <asm/system.h> +DECLARE_GLOBAL_DATA_PTR ; +int print_cpuinfo (void ) {printf ("CPU: Airoha AN7581\n" );@@ -14,12 +18,23 @@ int print_cpuinfo(void)Quoted 13 lines
arch/arm/mach-airoha/an7581/init.c int print_cpuinfo(void) · line 27
Quoted 10 lines
arch/arm/mach-airoha/an7581/init.c +7
-1int dram_init (void ) { -return fdtdec_setup_mem_size_base (); +int ret; + + ret =fdtdec_setup_mem_size_base (); +if (ret) +return ret; + + gd->ram_size =get_ram_size ((void *)gd->ram_base,SZ_8G );Can we use a memory size passed by airoha trusted firmware instead of playing with
get_ram_size()?
Quoted 7 lines
Hi I received some feedback from Airoha about this and sadly it's not possible. There are too much version of ATF and only some of them provide RAM size in some way or another. Also there isn't an exact HW trap to read to know the RAM size hence raw testing the ram and not depending externally is the only solution :(
I will address all the other comments.
great.
Quoted 37 lines
Quoted 37 lines
arch/arm/mach-airoha/an7581/init.c int print_cpuinfo(void) · line 35
Quoted 9 lines
arch/arm/mach-airoha/an7581/init.c +4
-1+ +return 0 ; }int dram_init_banksize (void ) { -return fdtdec_setup_memory_banksize (); + gd->bd->bi_dram[0 ].start = gd->ram_base; + gd->bd->bi_dram[0 ].size = gd->ram_size;as I know u-boot can safely use only 2Gb of memory, thus it's better
#define CFG_MAX_MEM_MAPPED
SZ_2Gand replace above line with
gd->bd->bi_dram[0].size =
get_effective_memsize();Quoted 20 lines
arch/arm/mach-airoha/an7581/init.c +4
-2+ +return 0 ; }void reset_cpu (void )@@ -32,12 +47,12 @@ static struct mm_region an7581_mem_map[] = {/* DDR */ .virt = 0x80000000UL, .phys = 0x80000000UL, - .size = 0x80000000UL, + .size = 0x200000000ULL, .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE, }, { .virt = 0x00000000UL, .phys = 0x00000000UL, - .size =0x20000000UL , + .size =0x40000000UL , .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |PTE_BLOCK_NON_SHARE |PTE_BLOCK_PXN |PTE_BLOCK_UXN
Quoted 48 lines · Mikhail Kshevetskiy
Quoted 46 lines · Christian Marangi
Quoted 45 lines · Mikhail Kshevetskiy
Quoted 31 lines · Christian Marangi
There are multiple version of the same reference board with different RAM size and it's not enough to base the RAM size entirely from DT. To better support it use the
get_ram_sizeway to scan for the actual RAM size of Airoha SoC and increase the size of the memory map.Signed-off-by Christian Marangi <[email protected]>--- arch/arm/mach-airoha/an7581/init.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)arch/arm/mach-airoha/an7581/init.c +4
-0@@ -2,10 +2,14 @@#include <fdtdec.h> #include <init.h> +#include <linux/sizes.h> #include <sysreset.h> #include <asm/armv8/mmu.h> +#include <asm/global_data.h> #include <asm/system.h> +DECLARE_GLOBAL_DATA_PTR ; +int print_cpuinfo (void ) {printf ("CPU: Airoha AN7581\n" );@@ -14,12 +18,23 @@ int print_cpuinfo(void)arch/arm/mach-airoha/an7581/init.c int print_cpuinfo(void) · line 27
Quoted 10 lines
arch/arm/mach-airoha/an7581/init.c +7
-1int dram_init (void ) { -return fdtdec_setup_mem_size_base (); +int ret; + + ret =fdtdec_setup_mem_size_base (); +if (ret) +return ret; + + gd->ram_size =get_ram_size ((void *)gd->ram_base,SZ_8G );Can we use a memory size passed by airoha trusted firmware instead of playing with
get_ram_size()?
Quoted 21 lines
Quoted 7 lines
Hi I received some feedback from Airoha about this and sadly it's not possible. There are too much version of ATF and only some of them provide RAM size in some way or another. Also there isn't an exact HW trap to read to know the RAM size hence raw testing the ram and not depending externally is the only solution :(
I will address all the other comments.
great.
Quoted 13 lines
Quoted 13 lines
arch/arm/mach-airoha/an7581/init.c int print_cpuinfo(void) · line 35
Quoted 9 lines
arch/arm/mach-airoha/an7581/init.c +4
-1+ +return 0 ; }int dram_init_banksize (void ) { -return fdtdec_setup_memory_banksize (); + gd->bd->bi_dram[0 ].start = gd->ram_base; + gd->bd->bi_dram[0 ].size = gd->ram_size;as I know u-boot can safely use only 2Gb of memory, thus it's better
#define CFG_MAX_MEM_MAPPED
SZ_2G
Sorry for coming back on this but by declaring CFG_MAX_MEM_MAPPED aren't we limiting the memory to 2gb? Also these info are passed to the kernel so we are limiting the RAM also there. Am I wrong?
Also I notice the weak function dram_init_banksize is exactly the current one with the usage of effective ram so I guess I can drop it entirely?
Can you help me understand the usage of MAX_MEM_MAPPED and confirm this doesn't limit the total RAM when loading the kernel? (we don't use ATAGS as we use FDT)
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
and replace above line with
gd->bd->bi_dram[0].size =
get_effective_memsize();Quoted 20 lines
arch/arm/mach-airoha/an7581/init.c +4
-2+ +return 0 ; }void reset_cpu (void )@@ -32,12 +47,12 @@ static struct mm_region an7581_mem_map[] = {/* DDR */ .virt = 0x80000000UL, .phys = 0x80000000UL, - .size = 0x80000000UL, + .size = 0x200000000ULL, .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE, }, { .virt = 0x00000000UL, .phys = 0x00000000UL, - .size =0x20000000UL , + .size =0x40000000UL , .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |PTE_BLOCK_NON_SHARE |PTE_BLOCK_PXN |PTE_BLOCK_UXN
Signature · 1 line
Ansuel
Quoted 67 lines · Christian Marangi
Quoted 66 lines · Mikhail Kshevetskiy
Quoted 46 lines · Christian Marangi
Quoted 32 lines · Mikhail Kshevetskiy
Quoted 31 lines · Christian Marangi
There are multiple version of the same reference board with different RAM size and it's not enough to base the RAM size entirely from DT. To better support it use the
get_ram_sizeway to scan for the actual RAM size of Airoha SoC and increase the size of the memory map.Signed-off-by Christian Marangi <[email protected]>--- arch/arm/mach-airoha/an7581/init.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)arch/arm/mach-airoha/an7581/init.c +4
-0@@ -2,10 +2,14 @@#include <fdtdec.h> #include <init.h> +#include <linux/sizes.h> #include <sysreset.h> #include <asm/armv8/mmu.h> +#include <asm/global_data.h> #include <asm/system.h> +DECLARE_GLOBAL_DATA_PTR ; +int print_cpuinfo (void ) {printf ("CPU: Airoha AN7581\n" );@@ -14,12 +18,23 @@ int print_cpuinfo(void)Quoted 13 lines
arch/arm/mach-airoha/an7581/init.c int print_cpuinfo(void) · line 27
Quoted 10 lines
arch/arm/mach-airoha/an7581/init.c +7
-1int dram_init (void ) { -return fdtdec_setup_mem_size_base (); +int ret; + + ret =fdtdec_setup_mem_size_base (); +if (ret) +return ret; + + gd->ram_size =get_ram_size ((void *)gd->ram_base,SZ_8G );Can we use a memory size passed by airoha trusted firmware instead of playing with
get_ram_size()?Quoted 7 lines
Hi I received some feedback from Airoha about this and sadly it's not possible. There are too much version of ATF and only some of them provide RAM size in some way or another. Also there isn't an exact HW trap to read to know the RAM size hence raw testing the ram and not depending externally is the only solution :(
I will address all the other comments.
great.
Quoted 11 lines
Quoted 11 lines
arch/arm/mach-airoha/an7581/init.c int print_cpuinfo(void) · line 35
Quoted 9 lines
arch/arm/mach-airoha/an7581/init.c +4
-1+ +return 0 ; }int dram_init_banksize (void ) { -return fdtdec_setup_memory_banksize (); + gd->bd->bi_dram[0 ].start = gd->ram_base; + gd->bd->bi_dram[0 ].size = gd->ram_size;as I know u-boot can safely use only 2Gb of memory, thus it's better
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
#define CFG_MAX_MEM_MAPPED
SZ_2GSorry for coming back on this but by declaring
CFG_MAX_MEM_MAPPEDaren't we limiting the memory to 2gb? Also these info are passed to the kernel so we are limiting the RAM also there. Am I wrong?
You might be right. I don't remember where this knowledge could have come to me from.
I'll read arm documentation and look to a code to study an issue. I hope I will have enough time for it on Monday-Tuesday.
Quoted 3 lines
Also I notice the weak function
dram_init_banksizeis exactly the current one with the usage of effective ram so I guess I can drop it entirely?
looks reasonable.
Quoted 4 lines
Can you help me understand the usage of
MAX_MEM_MAPPEDand confirm this doesn't limit the total RAM when loading the kernel? (we don't use ATAGS as we use FDT)
will try make it clear for me as well, see above
Mikhail Kshevetskiy
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
and replace above line with
gd->bd->bi_dram[0].size =
get_effective_memsize();Quoted 20 lines
arch/arm/mach-airoha/an7581/init.c +4
-2+ +return 0 ; }void reset_cpu (void )@@ -32,12 +47,12 @@ static struct mm_region an7581_mem_map[] = {/* DDR */ .virt = 0x80000000UL, .phys = 0x80000000UL, - .size = 0x80000000UL, + .size = 0x200000000ULL, .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE, }, { .virt = 0x00000000UL, .phys = 0x00000000UL, - .size =0x20000000UL , + .size =0x40000000UL , .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |PTE_BLOCK_NON_SHARE |PTE_BLOCK_PXN |PTE_BLOCK_UXN
please see 0x00_8000_0000 -- 0x00_FFFF_FFFF region of memory from
https://developer.arm.com/documentation/100961/1100-00/Programming-Reference/ARMv8-A-Foundation-Platform-memory-map
According to it we will have only 2 Gb of memory started from 0x00_8000_0000.
Mikhail
Quoted 105 lines · Christian Marangi
Quoted 47 lines · Mikhail Kshevetskiy
Quoted 46 lines · Christian Marangi
Quoted 45 lines · Mikhail Kshevetskiy
Quoted 31 lines · Christian Marangi
There are multiple version of the same reference board with different RAM size and it's not enough to base the RAM size entirely from DT. To better support it use the
get_ram_sizeway to scan for the actual RAM size of Airoha SoC and increase the size of the memory map.Signed-off-by Christian Marangi <[email protected]>--- arch/arm/mach-airoha/an7581/init.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)arch/arm/mach-airoha/an7581/init.c +4
-0@@ -2,10 +2,14 @@#include <fdtdec.h> #include <init.h> +#include <linux/sizes.h> #include <sysreset.h> #include <asm/armv8/mmu.h> +#include <asm/global_data.h> #include <asm/system.h> +DECLARE_GLOBAL_DATA_PTR ; +int print_cpuinfo (void ) {printf ("CPU: Airoha AN7581\n" );@@ -14,12 +18,23 @@ int print_cpuinfo(void)arch/arm/mach-airoha/an7581/init.c int print_cpuinfo(void) · line 27
Quoted 10 lines
arch/arm/mach-airoha/an7581/init.c +7
-1int dram_init (void ) { -return fdtdec_setup_mem_size_base (); +int ret; + + ret =fdtdec_setup_mem_size_base (); +if (ret) +return ret; + + gd->ram_size =get_ram_size ((void *)gd->ram_base,SZ_8G );Can we use a memory size passed by airoha trusted firmware instead of playing with
get_ram_size()?Quoted 21 lines
Quoted 7 lines
Hi I received some feedback from Airoha about this and sadly it's not possible. There are too much version of ATF and only some of them provide RAM size in some way or another. Also there isn't an exact HW trap to read to know the RAM size hence raw testing the ram and not depending externally is the only solution :(
I will address all the other comments.
great.
Quoted 13 lines
Quoted 13 lines
arch/arm/mach-airoha/an7581/init.c int print_cpuinfo(void) · line 35
Quoted 9 lines
arch/arm/mach-airoha/an7581/init.c +4
-1+ +return 0 ; }int dram_init_banksize (void ) { -return fdtdec_setup_memory_banksize (); + gd->bd->bi_dram[0 ].start = gd->ram_base; + gd->bd->bi_dram[0 ].size = gd->ram_size;as I know u-boot can safely use only 2Gb of memory, thus it's better
#define CFG_MAX_MEM_MAPPED
SZ_2GSorry for coming back on this but by declaring
CFG_MAX_MEM_MAPPEDaren't we limiting the memory to 2gb? Also these info are passed to the kernel so we are limiting the RAM also there. Am I wrong?Also I notice the weak function
dram_init_banksizeis exactly the current one with the usage of effective ram so I guess I can drop it entirely?Can you help me understand the usage of
MAX_MEM_MAPPEDand confirm this doesn't limit the total RAM when loading the kernel? (we don't use ATAGS as we use FDT)Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
and replace above line with
gd->bd->bi_dram[0].size =
get_effective_memsize();Quoted 20 lines
arch/arm/mach-airoha/an7581/init.c +4
-2+ +return 0 ; }void reset_cpu (void )@@ -32,12 +47,12 @@ static struct mm_region an7581_mem_map[] = {/* DDR */ .virt = 0x80000000UL, .phys = 0x80000000UL, - .size = 0x80000000UL, + .size = 0x200000000ULL, .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE, }, { .virt = 0x00000000UL, .phys = 0x00000000UL, - .size =0x20000000UL , + .size =0x40000000UL , .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |PTE_BLOCK_NON_SHARE |PTE_BLOCK_PXN |PTE_BLOCK_UXN
Quoted 6 lines · Mikhail Kshevetskiy
External email : Please do not click links or open attachments until you have verified the sender or the content.
please see 0x00_8000_0000 -- 0x00_FFFF_FFFF region of memory from
Quoted 3 lines
According to it we will have only 2 Gb of memory started from 0x00_8000_0000.
The ARMv8-A Foundation Platform from the link is a simulation model, not an architecture that must be applied to all real armv8 ICs.
Quoted 133 lines
Mikhail
Quoted 129 lines · Christian Marangi
Quoted 66 lines · Mikhail Kshevetskiy
Quoted 65 lines · Christian Marangi
Quoted 37 lines · Mikhail Kshevetskiy
Quoted 36 lines · Christian Marangi
There are multiple version of the same reference board with different
RAM size and it's not enough to base the RAM size entirely from DT. To
better support it use theget_ram_sizeway to scan for the actual RAM
size of Airoha SoC and increase the size of the memory map.Signed-off-by Christian Marangi <[email protected]>--- arch/arm/mach-airoha/an7581/init.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)arch/arm/mach-airoha/an7581/init.c +4
-0@@ -2,10 +2,14 @@#include <fdtdec.h> #include <init.h> +#include <linux/sizes.h> #include <sysreset.h> #include <asm/armv8/mmu.h> +#include <asm/global_data.h> #include <asm/system.h> +DECLARE_GLOBAL_DATA_PTR ; +int print_cpuinfo (void ) {printf ("CPU: Airoha AN7581\n" );@@ -14,12 +18,23 @@ int print_cpuinfo(void)Quoted 15 lines
arch/arm/mach-airoha/an7581/init.c int print_cpuinfo(void) · line 27
Quoted 10 lines
arch/arm/mach-airoha/an7581/init.c +7
-1int dram_init (void ) { -return fdtdec_setup_mem_size_base (); +int ret; + + ret =fdtdec_setup_mem_size_base (); +if (ret) +return ret; + + gd->ram_size =get_ram_size ((void *)gd->ram_base,SZ_8G );Can we use a memory size passed by airoha trusted firmware instead of
playing withget_ram_size()?Hi I received some feedback from Airoha about this and sadly it's not
possible. There are too much version of ATF and only some of them
provide RAM size in some way or another. Also there isn't an exact HW
trap to read to know the RAM size hence raw testing the ram and not
depending externally is the only solution :(Quoted 18 lines
Quoted 1 line
I will address all the other comments.
great.
Quoted 15 lines
Quoted 15 lines
arch/arm/mach-airoha/an7581/init.c int print_cpuinfo(void) · line 35
Quoted 9 lines
arch/arm/mach-airoha/an7581/init.c +4
-1+ +return 0 ; }int dram_init_banksize (void ) { -return fdtdec_setup_memory_banksize (); + gd->bd->bi_dram[0 ].start = gd->ram_base; + gd->bd->bi_dram[0 ].size = gd->ram_size;as I know u-boot can safely use only 2Gb of memory, thus it's better
#define CFG_MAX_MEM_MAPPED SZ_2GSorry for coming back on this but by declaring
CFG_MAX_MEM_MAPPEDaren't we limiting the memory to 2gb? Also these info are passed to the
kernel so we are limiting the RAM also there. Am I wrong?Also I notice the weak function
dram_init_banksizeis exactly the current one with the usage of effective ram so I guess I can drop it
entirely?Can you help me understand the usage of
MAX_MEM_MAPPEDand confirm this
doesn't limit the total RAM when loading the kernel? (we don't use ATAGS
as we use FDT)Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
and replace above line with
gd->bd->bi_dram[0].size = get_effective_memsize();Quoted 22 lines
arch/arm/mach-airoha/an7581/init.c +4
-2+ +return 0 ; }void reset_cpu (void )@@ -32,12 +47,12 @@ static struct mm_region an7581_mem_map[] = { /* DDR */ .virt = 0x80000000UL, .phys = 0x80000000UL, - .size = 0x80000000UL, + .size = 0x200000000ULL, .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE, }, { .virt = 0x00000000UL, .phys = 0x00000000UL, - .size = 0x20000000UL, + .size = 0x40000000UL, .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
PTE_BLOCK_NON_SHARE|
PTE_BLOCK_PXN|PTE_BLOCK_UXN
I think to get an answer we need:
1) Physical address map of an7581 chips. Could you ask it from airoha?
2) Find out a list of devices that supports DMA with 32-bit addresses only.
If there are two (or more) memory regions (like in
https://developer.arm.com/documentation/100961/1100-00/Programming-Reference/ARMv8-A-Foundation-Platform-memory-map)
we need to configure them separately (see arch/arm/mach-exynos/mmu-arm64.c file, exynos850_mem_map array).
If we have a single region started at 0x80000000, but there is a device that supports 32-bit DMA only, then we should split this memory region on 2 regions. The first will be limited by 2Gb, and the second will cover rest of memory.
In both above cases we will need to restrict u-boot to use only first memory region (not dig it yet).
Regards,
Mikhail Kshevetskiy
Quoted 105 lines · Christian Marangi
Quoted 47 lines · Mikhail Kshevetskiy
Quoted 46 lines · Christian Marangi
Quoted 45 lines · Mikhail Kshevetskiy
Quoted 31 lines · Christian Marangi
There are multiple version of the same reference board with different RAM size and it's not enough to base the RAM size entirely from DT. To better support it use the
get_ram_sizeway to scan for the actual RAM size of Airoha SoC and increase the size of the memory map.Signed-off-by Christian Marangi <[email protected]>--- arch/arm/mach-airoha/an7581/init.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)arch/arm/mach-airoha/an7581/init.c +4
-0@@ -2,10 +2,14 @@#include <fdtdec.h> #include <init.h> +#include <linux/sizes.h> #include <sysreset.h> #include <asm/armv8/mmu.h> +#include <asm/global_data.h> #include <asm/system.h> +DECLARE_GLOBAL_DATA_PTR ; +int print_cpuinfo (void ) {printf ("CPU: Airoha AN7581\n" );@@ -14,12 +18,23 @@ int print_cpuinfo(void)arch/arm/mach-airoha/an7581/init.c int print_cpuinfo(void) · line 27
Quoted 10 lines
arch/arm/mach-airoha/an7581/init.c +7
-1int dram_init (void ) { -return fdtdec_setup_mem_size_base (); +int ret; + + ret =fdtdec_setup_mem_size_base (); +if (ret) +return ret; + + gd->ram_size =get_ram_size ((void *)gd->ram_base,SZ_8G );Can we use a memory size passed by airoha trusted firmware instead of playing with
get_ram_size()?Quoted 21 lines
Quoted 7 lines
Hi I received some feedback from Airoha about this and sadly it's not possible. There are too much version of ATF and only some of them provide RAM size in some way or another. Also there isn't an exact HW trap to read to know the RAM size hence raw testing the ram and not depending externally is the only solution :(
I will address all the other comments.
great.
Quoted 13 lines
Quoted 13 lines
arch/arm/mach-airoha/an7581/init.c int print_cpuinfo(void) · line 35
Quoted 9 lines
arch/arm/mach-airoha/an7581/init.c +4
-1+ +return 0 ; }int dram_init_banksize (void ) { -return fdtdec_setup_memory_banksize (); + gd->bd->bi_dram[0 ].start = gd->ram_base; + gd->bd->bi_dram[0 ].size = gd->ram_size;as I know u-boot can safely use only 2Gb of memory, thus it's better
#define CFG_MAX_MEM_MAPPED
SZ_2GSorry for coming back on this but by declaring
CFG_MAX_MEM_MAPPEDaren't we limiting the memory to 2gb? Also these info are passed to the kernel so we are limiting the RAM also there. Am I wrong?Also I notice the weak function
dram_init_banksizeis exactly the current one with the usage of effective ram so I guess I can drop it entirely?Can you help me understand the usage of
MAX_MEM_MAPPEDand confirm this doesn't limit the total RAM when loading the kernel? (we don't use ATAGS as we use FDT)Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
and replace above line with
gd->bd->bi_dram[0].size =
get_effective_memsize();Quoted 20 lines
arch/arm/mach-airoha/an7581/init.c +4
-2+ +return 0 ; }void reset_cpu (void )@@ -32,12 +47,12 @@ static struct mm_region an7581_mem_map[] = {/* DDR */ .virt = 0x80000000UL, .phys = 0x80000000UL, - .size = 0x80000000UL, + .size = 0x200000000ULL, .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE, }, { .virt = 0x00000000UL, .phys = 0x00000000UL, - .size =0x20000000UL , + .size =0x40000000UL , .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |PTE_BLOCK_NON_SHARE |PTE_BLOCK_PXN |PTE_BLOCK_UXN