meson-gx: reserved memory regions
Subsystems (3)
RFC 1/1 meson-gx: reserved memory regions
From: Heinrich Schuchardt <[email protected]>
The Odroid C2 has two GiB of memory with two reserved regions. reg = <0x0 0x0 0x0 0x1000000>;
reg = <0x0 0x10000000 0x0 0x200000>;
The description has been created with the following patches:
Patchbfcef28ae4cf (arm: add initial support for Amlogic Meson and ODROID-C2) defined the available memory in arch/arm/dts/meson-gxbb-odroidc2.dts as reg = <0x0 0x0 0x0 0x80000000> and the number of RAM banks as #define CONFIG_NR_DRAM_BANKS 1.
Patch4b3ab59d21ef (configs: gxbb: Introduce a common config header file) moved the number of RAM banks to include/configs/meson-gxbb-common.h.
Patcha3b02a1d4926 (arm: dts: update Meson GXBB / Odroid-C2 DT with recent) defined two reserved memory regions in arch/arm/dts/meson-gx.dtsi.
U-Boot does not support the concept of reserved memory regions.
Amongst other mishaps this leads to a wrong memory configuration when calling bootefi which may cause a memory violation.
The easiest way to correct this is to define multiple memory banks.
In the long run fdt support for reserved-memory might be implemented.
--- arch/arm/dts/meson-gxbb-odroidc2.dts | 7 ++++++- include/configs/meson-gxbb-common.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-)
arch/arm/dts/meson-gxbb-odroidc2.dts +6 -1
@@ -61,7 +61,12 @@ memory at 0 { device_type = "memory"; - reg = <0x0 0x0 0x0 0x80000000>; + reg =<0x0 0x1000000 0x0 0xf000000>; + }; + + memory at 1 { + device_type = "memory"; + reg = <0x0 0x10200000 0x0 0x6fe00000>; }; usb_otg_pwr: regulator-usb-pwrs {
include/configs/meson-gxbb-common.h +1 -1
@@ -10,7 +10,7 @@#define CONFIG_CPU_ARMV8 #define CONFIG_REMAKE_ELF -#define CONFIG_NR_DRAM_BANKS 1 +#define CONFIG_NR_DRAM_BANKS 2#define CONFIG_ENV_IS_NOWHERE 1#define CONFIG_ENV_SIZE 0x2000#define CONFIG_SYS_MAXARGS 32
Signature · 1 line
2.11.0
RFC 1/1 meson-gx: reserved memory regions
Am 09.06.2017 um 17:43 schrieb Heinrich at suse.de:
Quoted 18 lines
From: Heinrich Schuchardt <[email protected]>
The Odroid C2 has two GiB of memory with two reserved regions. reg = <
0x00x00x00x1000000>;
reg = <0x00x100000000x00x200000>;The description has been created with the following patches:
Patch
bfcef28ae4cf(arm: add initial support for Amlogic Meson and ODROID-C2) defined the available memory inarch/arm/dts/meson-gxbb-odroidc2.dtsas reg = <0x00x00x00x80000000> and the number of RAM banks as #defineCONFIG_NR_DRAM_BANKS1.Patch
4b3ab59d21ef(configs: gxbb: Introduce a common config header file) moved the number of RAM banks toinclude/configs/meson-gxbb-common.h.
Quoted 8 lines
Patch
a3b02a1d4926(arm: dts: update Meson GXBB / Odroid-C2 DT with recent) defined two reserved memory regions inarch/arm/dts/meson-gx.dtsi.U-Boot does not support the concept of reserved memory regions.
Amongst other mishaps this leads to a wrong memory configuration when calling bootefi which may cause a memory violation.
Please share what symptoms you are seeing. I have been using bootefi with GRUB without problems for many months on Odroid-C2, Vega S95 and recently NanoPi K2. v4.12-rc3 was probably the last kernel I tested.
Quoted 4 lines
The easiest way to correct this is to define multiple memory banks.
In the long run fdt support for reserved-memory might be implemented.
Have you looked into that at all? It seems a one-time change that would benefit all platforms rather than a single board here. I'd imagine a simple loop over sub-nodes of /reserved-memory that then calls the existing EFI memory reservation function. (In particular I would hope that might fix e.g. 32-bit sunxi.)
Quoted 12 lines
Signed-off-by Heinrich Schuchardt <[email protected]>--- arch/arm/dts/meson-gxbb-odroidc2.dts | 7 ++++++- include/configs/meson-gxbb-common.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-)arch/arm/dts/meson-gxbb-odroidc2.dts +0
-0
arch/arm/dts/meson-gxbb-odroidc2.dts line 67
Quoted 8 lines
arch/arm/dts/meson-gxbb-odroidc2.dts +4
-1@@ -61,7 +61,12 @@ memory at 0 { device_type = "memory"; - reg = <0x0 0x0 0x0 0x80000000>; + reg =<0x0 0x1000000 0x0 0xf000000>; + }; + + memory at 1 {
This is wrong. memory at 10200000 if at all.
arch/arm/dts/meson-gxbb-odroidc2.dts line 69
Quoted 2 lines
arch/arm/dts/meson-gxbb-odroidc2.dts +2
-0+ device_type = "memory"; + reg = <0x0 0x10200000 0x0 0x6fe00000>;
Please don't randomly modify the .dts in ways incompatible with Linux.
If we need two DRAM banks, then this needs to be implemented in board or mach code.
Regards,
Andreas
Quoted 17 lines
arch/arm/dts/meson-gxbb-odroidc2.dts +0
-0}; usb_otg_pwr: regulator-usb-pwrs {include/configs/meson-gxbb-common.h +1
-1@@ -10,7 +10,7 @@#define CONFIG_CPU_ARMV8 #define CONFIG_REMAKE_ELF -#define CONFIG_NR_DRAM_BANKS 1 +#define CONFIG_NR_DRAM_BANKS 2#define CONFIG_ENV_IS_NOWHERE 1#define CONFIG_ENV_SIZE 0x2000#define CONFIG_SYS_MAXARGS 32
Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg)
PATCH v2 1/1 meson-gx: reserved memory regions
The Odroid C2 has two GiB of memory with two reserved regions. reg = <0x0 0x0 0x0 0x1000000>;
reg = <0x0 0x10000000 0x0 0x200000>;
Patchbfcef28ae4cf (arm: add initial support for Amlogic Meson and ODROID-C2) provided function dram_init_banksize to reserve the first 16 MiB of RAM for firmware in function dram_init_banksize in arch/arm/mach-meson/board.c and defined CONFIG_NR_DRAM_BANKS = 1.
With this patch dram_init_banksize is changed to additionally reserve the 2MiB region for the ARM Trusted Firmware (BL31). CONFIG_NR_DRAM_BANKS is set to 2.
---
v2:
Do not change the dtb but the board file as suggested by Andreas Färber.
--- arch/arm/mach-meson/board.c | 8 +++++--- include/configs/meson-gxbb-common.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-)
arch/arm/mach-meson/board.c +5 -3
@@ -37,9 +37,11 @@ int dram_init(void)int dram_init_banksize (void ) {/* Reserve first 16 MiB of RAM for firmware */ - gd->bd->bi_dram[0 ].start =CONFIG_SYS_SDRAM_BASE + (16 *1024 *1024 ); - gd->bd->bi_dram[0 ].size = gd->ram_size - (16 *1024 *1024 ); - + gd->bd->bi_dram[0 ].start =0x1000000 ; + gd->bd->bi_dram[0 ].size =0xf000000 ; +/* Reserve 2 MiB for ARM Trusted Firmware (BL31) */ + gd->bd->bi_dram[1 ].start =0x10000000 ; + gd->bd->bi_dram[1 ].size = gd->ram_size -0x10200000 ;return 0 ; }
include/configs/meson-gxbb-common.h +1 -1
@@ -10,7 +10,7 @@#define CONFIG_CPU_ARMV8 #define CONFIG_REMAKE_ELF -#define CONFIG_NR_DRAM_BANKS 1 +#define CONFIG_NR_DRAM_BANKS 2#define CONFIG_ENV_IS_NOWHERE 1#define CONFIG_ENV_SIZE 0x2000#define CONFIG_SYS_MAXARGS 32
Signature · 1 line
2.11.0
PATCH v2 1/1 meson-gx: reserved memory regions
Hello Tom, hello Albert,
I did not see any objections.
Can this be merged?
https://patchwork.ozlabs.org/patch/774142/
Best regards
Heinrich
Quoted 59 lines · Heinrich Schuchardt
The Odroid C2 has two GiB of memory with two reserved regions. reg = <
0x00x00x00x1000000>;
reg = <0x00x100000000x00x200000>;Patch
bfcef28ae4cf(arm: add initial support for Amlogic Meson and ODROID-C2) provided functiondram_init_banksizeto reserve the first 16 MiB of RAM for firmware in functiondram_init_banksizeinarch/arm/mach-meson/board.cand definedCONFIG_NR_DRAM_BANKS= 1.With this patch
dram_init_banksizeis changed to additionally reserve the 2MiB region for the ARM Trusted Firmware (BL31).CONFIG_NR_DRAM_BANKSis set to 2.Cc Andreas Färber <[email protected]>Signed-off-by Heinrich Schuchardt <[email protected]>---
v2:
Do not change the dtb but the board file as suggested by Andreas Färber.--- arch/arm/mach-meson/board.c | 8 +++++--- include/configs/meson-gxbb-common.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-)arch/arm/mach-meson/board.c +5
-3@@ -37,9 +37,11 @@ int dram_init(void)int dram_init_banksize (void ) {/* Reserve first 16 MiB of RAM for firmware */ - gd->bd->bi_dram[0 ].start =CONFIG_SYS_SDRAM_BASE + (16 *1024 *1024 ); - gd->bd->bi_dram[0 ].size = gd->ram_size - (16 *1024 *1024 ); - + gd->bd->bi_dram[0 ].start =0x1000000 ; + gd->bd->bi_dram[0 ].size =0xf000000 ; +/* Reserve 2 MiB for ARM Trusted Firmware (BL31) */ + gd->bd->bi_dram[1 ].start =0x10000000 ; + gd->bd->bi_dram[1 ].size = gd->ram_size -0x10200000 ;return 0 ; }include/configs/meson-gxbb-common.h +1
-1@@ -10,7 +10,7 @@#define CONFIG_CPU_ARMV8 #define CONFIG_REMAKE_ELF -#define CONFIG_NR_DRAM_BANKS 1 +#define CONFIG_NR_DRAM_BANKS 2#define CONFIG_ENV_IS_NOWHERE 1#define CONFIG_ENV_SIZE 0x2000#define CONFIG_SYS_MAXARGS 32
PATCH v2 1/1 meson-gx: reserved memory regions
In reply to Heinrich SchuchardtQuoted 11 lines · xypron.glpk at gmx.de
The Odroid C2 has two GiB of memory with two reserved regions. reg = <
0x00x00x00x1000000>;
reg = <0x00x100000000x00x200000>;Patch
bfcef28ae4cf(arm: add initial support for Amlogic Meson and ODROID-C2) provided functiondram_init_banksizeto reserve the first 16 MiB of RAM for firmware in functiondram_init_banksizeinarch/arm/mach-meson/board.cand definedCONFIG_NR_DRAM_BANKS= 1.
Quoted 6 lines
With this patch
dram_init_banksizeis changed to additionally reserve the 2MiB region for the ARM Trusted Firmware (BL31).CONFIG_NR_DRAM_BANKSis set to 2.Cc Andreas Färber <[email protected]>Signed-off-by Heinrich Schuchardt <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170724/645bb44c/attachment-0001.sig>