[U-Boot] [RFC 1/1] meson-gx: reserved memory regions

From: Heinrich Schuchardt xypron.glpk@gmx.de
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:
Patch bfcef28ae4cf (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.
Patch 4b3ab59d21ef (configs: gxbb: Introduce a common config header file) moved the number of RAM banks to include/configs/meson-gxbb-common.h.
Patch a3b02a1d4926 (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.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- arch/arm/dts/meson-gxbb-odroidc2.dts | 7 ++++++- include/configs/meson-gxbb-common.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/arch/arm/dts/meson-gxbb-odroidc2.dts b/arch/arm/dts/meson-gxbb-odroidc2.dts index c737183a29..35b8300e23 100644 --- a/arch/arm/dts/meson-gxbb-odroidc2.dts +++ b/arch/arm/dts/meson-gxbb-odroidc2.dts @@ -61,7 +61,12 @@
memory@0 { device_type = "memory"; - reg = <0x0 0x0 0x0 0x80000000>; + reg =<0x0 0x1000000 0x0 0xf000000>; + }; + + memory@1 { + device_type = "memory"; + reg = <0x0 0x10200000 0x0 0x6fe00000>; };
usb_otg_pwr: regulator-usb-pwrs { diff --git a/include/configs/meson-gxbb-common.h b/include/configs/meson-gxbb-common.h index 89e3807a14..ed55f441a4 100644 --- a/include/configs/meson-gxbb-common.h +++ b/include/configs/meson-gxbb-common.h @@ -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

Am 09.06.2017 um 17:43 schrieb Heinrich@suse.de:
From: Heinrich Schuchardt xypron.glpk@gmx.de
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:
Patch bfcef28ae4cf (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.
Patch 4b3ab59d21ef (configs: gxbb: Introduce a common config header file) moved the number of RAM banks to include/configs/meson-gxbb-common.h.
Patch a3b02a1d4926 (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.
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.
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.)
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
arch/arm/dts/meson-gxbb-odroidc2.dts | 7 ++++++- include/configs/meson-gxbb-common.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/arch/arm/dts/meson-gxbb-odroidc2.dts b/arch/arm/dts/meson-gxbb-odroidc2.dts index c737183a29..35b8300e23 100644 --- a/arch/arm/dts/meson-gxbb-odroidc2.dts +++ b/arch/arm/dts/meson-gxbb-odroidc2.dts @@ -61,7 +61,12 @@
memory@0 { device_type = "memory";
reg = <0x0 0x0 0x0 0x80000000>;
reg =<0x0 0x1000000 0x0 0xf000000>;
- };
- memory@1 {
This is wrong. memory@10200000 if at all.
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
};
usb_otg_pwr: regulator-usb-pwrs { diff --git a/include/configs/meson-gxbb-common.h b/include/configs/meson-gxbb-common.h index 89e3807a14..ed55f441a4 100644 --- a/include/configs/meson-gxbb-common.h +++ b/include/configs/meson-gxbb-common.h @@ -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

The Odroid C2 has two GiB of memory with two reserved regions. reg = <0x0 0x0 0x0 0x1000000>; reg = <0x0 0x10000000 0x0 0x200000>;
Patch bfcef28ae4cf (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.
Cc: Andreas Färber afaerber@suse.de Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- 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(-)
diff --git a/arch/arm/mach-meson/board.c b/arch/arm/mach-meson/board.c index 273dbeb020..e89c6aace9 100644 --- a/arch/arm/mach-meson/board.c +++ b/arch/arm/mach-meson/board.c @@ -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; }
diff --git a/include/configs/meson-gxbb-common.h b/include/configs/meson-gxbb-common.h index 89e3807a14..ed55f441a4 100644 --- a/include/configs/meson-gxbb-common.h +++ b/include/configs/meson-gxbb-common.h @@ -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

Hello Tom, hello Albert,
I did not see any objections.
Can this be merged? https://patchwork.ozlabs.org/patch/774142/
Best regards
Heinrich
On 06/09/2017 10:13 PM, Heinrich Schuchardt wrote:
The Odroid C2 has two GiB of memory with two reserved regions. reg = <0x0 0x0 0x0 0x1000000>; reg = <0x0 0x10000000 0x0 0x200000>;
Patch bfcef28ae4cf (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.
Cc: Andreas Färber afaerber@suse.de Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
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(-)
diff --git a/arch/arm/mach-meson/board.c b/arch/arm/mach-meson/board.c index 273dbeb020..e89c6aace9 100644 --- a/arch/arm/mach-meson/board.c +++ b/arch/arm/mach-meson/board.c @@ -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;
}
diff --git a/include/configs/meson-gxbb-common.h b/include/configs/meson-gxbb-common.h index 89e3807a14..ed55f441a4 100644 --- a/include/configs/meson-gxbb-common.h +++ b/include/configs/meson-gxbb-common.h @@ -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

On Fri, Jun 09, 2017 at 10:13:59PM +0200, xypron.glpk@gmx.de wrote:
The Odroid C2 has two GiB of memory with two reserved regions. reg = <0x0 0x0 0x0 0x1000000>; reg = <0x0 0x10000000 0x0 0x200000>;
Patch bfcef28ae4cf (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.
Cc: Andreas Färber afaerber@suse.de Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
Applied to u-boot/master, thanks!
participants (4)
-
Andreas Färber
-
Heinrich Schuchardt
-
Heinrich@lists.denx.de
-
Tom Rini