public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/7] malloc_simple: Add support for switching to DRAM heap
@ 2015-09-13 15:42 Hans de Goede
  2015-09-13 15:42 ` [U-Boot] [PATCH 1/7] spl: spl_relocate_stack_gd: Do not unnecessarily clear bss Hans de Goede
                   ` (6 more replies)
  0 siblings, 7 replies; 21+ messages in thread
From: Hans de Goede @ 2015-09-13 15:42 UTC (permalink / raw)
  To: u-boot

Hi Simon,

Here is a patch-set to add support to keep using simple-malloc after dram
is available in the SPL, using the spl stack relocation function to
switch to a new heap which uses a chunk of the now in DRAM stack.

I think you're the best candidate to review and merge the core patches
(patches 1 - 4).

I'll merge the sunxi patches through my tree once the core patches are
in place. Esp. the patch to make sunxi use CONFIG_SPL_STACK_R is likely
to cause conflicts if not merged through the sunxi tree.

Regards,

Hans

p.s.

In case it is not clear, these patches are intended for the next devel cycle.

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

* [U-Boot] [PATCH 1/7] spl: spl_relocate_stack_gd: Do not unnecessarily clear bss
  2015-09-13 15:42 [U-Boot] [PATCH 0/7] malloc_simple: Add support for switching to DRAM heap Hans de Goede
@ 2015-09-13 15:42 ` Hans de Goede
  2015-09-22  4:00   ` Simon Glass
  2015-09-13 15:42 ` [U-Boot] [PATCH 2/7] malloc_simple: Fix malloc_ptr calculation Hans de Goede
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 21+ messages in thread
From: Hans de Goede @ 2015-09-13 15:42 UTC (permalink / raw)
  To: u-boot

spl_relocate_stack_gd only gets called from arch/arm/lib/crt0.S which
clears the bss directly after calling it, so there is no need to clear
it from spl_relocate_stack_gd.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 common/spl/spl.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index a5892d7..b09a626 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -347,9 +347,6 @@ ulong spl_relocate_stack_gd(void)
 	memcpy(new_gd, (void *)gd, sizeof(gd_t));
 	gd = new_gd;
 
-	/* Clear the BSS. */
-	memset(__bss_start, 0, __bss_end - __bss_start);
-
 	return ptr;
 #else
 	return 0;
-- 
2.4.3

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

* [U-Boot] [PATCH 2/7] malloc_simple: Fix malloc_ptr calculation
  2015-09-13 15:42 [U-Boot] [PATCH 0/7] malloc_simple: Add support for switching to DRAM heap Hans de Goede
  2015-09-13 15:42 ` [U-Boot] [PATCH 1/7] spl: spl_relocate_stack_gd: Do not unnecessarily clear bss Hans de Goede
@ 2015-09-13 15:42 ` Hans de Goede
  2015-09-22  4:00   ` Simon Glass
  2015-09-13 15:42 ` [U-Boot] [PATCH 3/7] malloc_simple: Add Kconfig option for using only malloc_simple in the SPL Hans de Goede
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 21+ messages in thread
From: Hans de Goede @ 2015-09-13 15:42 UTC (permalink / raw)
  To: u-boot

From: Philipp Rosenberger <ilu@linutronix.de>

The gd->malloc_ptr and the gd->malloc_limit are offsets to gd->malloc_base.
But the addr variable contains the absolute address. The new_ptr must be:
addr + bytes - gd->malloc_base.

Signed-off-by: Philipp Rosenberger <ilu@linutronix.de>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 common/malloc_simple.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/malloc_simple.c b/common/malloc_simple.c
index 134e059..c745863 100644
--- a/common/malloc_simple.c
+++ b/common/malloc_simple.c
@@ -32,7 +32,7 @@ void *memalign_simple(size_t align, size_t bytes)
 	void *ptr;
 
 	addr = ALIGN(gd->malloc_base + gd->malloc_ptr, align);
-	new_ptr = addr + bytes;
+	new_ptr = addr + bytes - gd->malloc_base;
 	if (new_ptr > gd->malloc_limit)
 		return NULL;
 	ptr = map_sysmem(addr, bytes);
-- 
2.4.3

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

* [U-Boot] [PATCH 3/7] malloc_simple: Add Kconfig option for using only malloc_simple in the SPL
  2015-09-13 15:42 [U-Boot] [PATCH 0/7] malloc_simple: Add support for switching to DRAM heap Hans de Goede
  2015-09-13 15:42 ` [U-Boot] [PATCH 1/7] spl: spl_relocate_stack_gd: Do not unnecessarily clear bss Hans de Goede
  2015-09-13 15:42 ` [U-Boot] [PATCH 2/7] malloc_simple: Fix malloc_ptr calculation Hans de Goede
@ 2015-09-13 15:42 ` Hans de Goede
  2015-09-22  4:00   ` Simon Glass
  2015-09-13 15:42 ` [U-Boot] [PATCH 4/7] malloc_simple: Add support for switching to DRAM heap Hans de Goede
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 21+ messages in thread
From: Hans de Goede @ 2015-09-13 15:42 UTC (permalink / raw)
  To: u-boot

common/dlmalloc.c is quite big, both in .text and .data usage, therefor
on some boards the SPL is build to use only malloc_simple.c and not the
dlmalloc.c code. This is done in various include/configs/foo.h with the
following construct:

This commit introduces a SPL_MALLOC_SIMPLE Kconfig bool which allows
selecting this functionality through Kconfig instead.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 Kconfig                | 10 ++++++++++
 common/malloc_simple.c |  3 ++-
 include/_exports.h     |  3 ++-
 include/exports.h      |  3 ++-
 include/malloc.h       |  3 ++-
 5 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/Kconfig b/Kconfig
index 05a34f7..0ae4fab 100644
--- a/Kconfig
+++ b/Kconfig
@@ -114,6 +114,16 @@ config SPL
 	help
 	  If you want to build SPL as well as the normal image, say Y.
 
+config SPL_MALLOC_SIMPLE
+	bool
+	depends on SPL
+	prompt "Only use malloc_simple functions in the spl"
+	help
+	  Say Y here to only use the *_simple malloc functions from
+	  malloc_simple.c, rather then using the versions from dlmalloc.c
+	  this will make the SPL binary smaller at the cost of more heap
+	  usage as the *_simple malloc functions do not re-use free-ed mem.
+
 config SPL_STACK_R
 	depends on SPL
 	bool "Enable SDRAM location for SPL stack"
diff --git a/common/malloc_simple.c b/common/malloc_simple.c
index c745863..e9c1eaa 100644
--- a/common/malloc_simple.c
+++ b/common/malloc_simple.c
@@ -40,7 +40,8 @@ void *memalign_simple(size_t align, size_t bytes)
 	return ptr;
 }
 
-#ifdef CONFIG_SYS_MALLOC_SIMPLE
+#if (defined CONFIG_SPL_BUILD && defined CONFIG_SPL_MALLOC_SIMPLE) || \
+    (defined CONFIG_SYS_MALLOC_SIMPLE)
 void *calloc(size_t nmemb, size_t elem_size)
 {
 	size_t size = nmemb * elem_size;
diff --git a/include/_exports.h b/include/_exports.h
index 74a882a..f811c5d 100644
--- a/include/_exports.h
+++ b/include/_exports.h
@@ -23,7 +23,8 @@
 	EXPORT_FUNC(dummy, void, free_hdlr, void)
 #endif
 	EXPORT_FUNC(malloc, void *, malloc, size_t)
-#ifndef CONFIG_SYS_MALLOC_SIMPLE
+#if !(defined CONFIG_SPL_BUILD && defined CONFIG_SPL_MALLOC_SIMPLE) && \
+    !(defined CONFIG_SYS_MALLOC_SIMPLE)
 	EXPORT_FUNC(free, void, free, void *)
 #endif
 	EXPORT_FUNC(udelay, void, udelay, unsigned long)
diff --git a/include/exports.h b/include/exports.h
index a3e0469..8171b31 100644
--- a/include/exports.h
+++ b/include/exports.h
@@ -19,7 +19,8 @@ int printf(const char* fmt, ...);
 void install_hdlr(int, interrupt_handler_t, void*);
 void free_hdlr(int);
 void *malloc(size_t);
-#ifndef CONFIG_SYS_MALLOC_SIMPLE
+#if !(defined CONFIG_SPL_BUILD && defined CONFIG_SPL_MALLOC_SIMPLE) && \
+    !(defined CONFIG_SYS_MALLOC_SIMPLE)
 void free(void*);
 #endif
 void __udelay(unsigned long);
diff --git a/include/malloc.h b/include/malloc.h
index f4da9e6..e5592fc 100644
--- a/include/malloc.h
+++ b/include/malloc.h
@@ -872,7 +872,8 @@ extern Void_t*     sbrk();
 
 #else
 
-#ifdef CONFIG_SYS_MALLOC_SIMPLE
+#if (defined CONFIG_SPL_BUILD && defined CONFIG_SPL_MALLOC_SIMPLE) || \
+    (defined CONFIG_SYS_MALLOC_SIMPLE)
 #define malloc malloc_simple
 #define realloc realloc_simple
 #define memalign memalign_simple
-- 
2.4.3

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

* [U-Boot] [PATCH 4/7] malloc_simple: Add support for switching to DRAM heap
  2015-09-13 15:42 [U-Boot] [PATCH 0/7] malloc_simple: Add support for switching to DRAM heap Hans de Goede
                   ` (2 preceding siblings ...)
  2015-09-13 15:42 ` [U-Boot] [PATCH 3/7] malloc_simple: Add Kconfig option for using only malloc_simple in the SPL Hans de Goede
@ 2015-09-13 15:42 ` Hans de Goede
  2015-09-22  4:00   ` Simon Glass
  2015-09-13 15:42 ` [U-Boot] [PATCH 5/7] sunxi: Simplify spl board_init_f function Hans de Goede
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 21+ messages in thread
From: Hans de Goede @ 2015-09-13 15:42 UTC (permalink / raw)
  To: u-boot

malloc_simple uses a part of the stack as heap, initially it uses
SYS_MALLOC_F_LEN bytes which typically is quite small as the initial
stacks sits in SRAM and we do not have that much SRAM to work with.

When DRAM becomes available we may switch the stack from SRAM to DRAM
to give use more room. This commit adds support for also switching to
a new bigger malloc_simple heap located in the new stack.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 Kconfig          | 10 ++++++++++
 common/spl/spl.c |  9 +++++++++
 2 files changed, 19 insertions(+)

diff --git a/Kconfig b/Kconfig
index 0ae4fab..86088bc 100644
--- a/Kconfig
+++ b/Kconfig
@@ -142,6 +142,16 @@ config SPL_STACK_R_ADDR
 	  Specify the address in SDRAM for the SPL stack. This will be set up
 	  before board_init_r() is called.
 
+config SPL_STACK_R_MALLOC_SIMPLE_LEN
+	depends on SPL_STACK_R && SPL_MALLOC_SIMPLE
+	hex "Size of malloc_simple heap after switching to DRAM SPL stack"
+	default 0x100000
+	help
+	  Specify the amount of the stack to use as memory pool for
+	  malloc_simple after switching the stack to DRAM. This may be set
+	  to give board_init_r() a larger heap then the initial heap in
+	  SRAM which is limited to SYS_MALLOC_F_LEN bytes.
+
 config TPL
 	bool
 	depends on SPL && SUPPORT_TPL
diff --git a/common/spl/spl.c b/common/spl/spl.c
index b09a626..8c2d109 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -347,6 +347,15 @@ ulong spl_relocate_stack_gd(void)
 	memcpy(new_gd, (void *)gd, sizeof(gd_t));
 	gd = new_gd;
 
+#ifdef CONFIG_SPL_MALLOC_SIMPLE
+	if (CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN) {
+		ptr -= CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN;
+		gd->malloc_base = ptr;
+		gd->malloc_limit = CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN;
+		gd->malloc_ptr = 0;
+	}
+#endif
+
 	return ptr;
 #else
 	return 0;
-- 
2.4.3

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

* [U-Boot] [PATCH 5/7] sunxi: Simplify spl board_init_f function
  2015-09-13 15:42 [U-Boot] [PATCH 0/7] malloc_simple: Add support for switching to DRAM heap Hans de Goede
                   ` (3 preceding siblings ...)
  2015-09-13 15:42 ` [U-Boot] [PATCH 4/7] malloc_simple: Add support for switching to DRAM heap Hans de Goede
@ 2015-09-13 15:42 ` Hans de Goede
  2015-09-13 16:27   ` Ian Campbell
  2015-09-13 15:42 ` [U-Boot] [PATCH 6/7] sunxi: Enable CONFIG_SPL_STACK_R Hans de Goede
  2015-09-13 15:42 ` [U-Boot] [PATCH 7/7] sunxi: Switch to using malloc_simple for the spl Hans de Goede
  6 siblings, 1 reply; 21+ messages in thread
From: Hans de Goede @ 2015-09-13 15:42 UTC (permalink / raw)
  To: u-boot

crt0.S will both memset the bss sectioan and call board_init_r for us,
so there is no need to do either ourselves.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 arch/arm/cpu/armv7/sunxi/board.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c
index b40198b..8883cf5 100644
--- a/arch/arm/cpu/armv7/sunxi/board.c
+++ b/arch/arm/cpu/armv7/sunxi/board.c
@@ -198,11 +198,6 @@ void board_init_f(ulong dummy)
 	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
 #endif
 	sunxi_board_init();
-
-	/* Clear the BSS. */
-	memset(__bss_start, 0, __bss_end - __bss_start);
-
-	board_init_r(NULL, 0);
 }
 #endif
 
-- 
2.4.3

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

* [U-Boot] [PATCH 6/7] sunxi: Enable CONFIG_SPL_STACK_R
  2015-09-13 15:42 [U-Boot] [PATCH 0/7] malloc_simple: Add support for switching to DRAM heap Hans de Goede
                   ` (4 preceding siblings ...)
  2015-09-13 15:42 ` [U-Boot] [PATCH 5/7] sunxi: Simplify spl board_init_f function Hans de Goede
@ 2015-09-13 15:42 ` Hans de Goede
  2015-09-13 16:33   ` Ian Campbell
  2015-09-13 15:42 ` [U-Boot] [PATCH 7/7] sunxi: Switch to using malloc_simple for the spl Hans de Goede
  6 siblings, 1 reply; 21+ messages in thread
From: Hans de Goede @ 2015-09-13 15:42 UTC (permalink / raw)
  To: u-boot

Select CONFIG_SPL_STACK_R for sunxi boards, this gives us much more
room on the stack once we've the DRAM running.

Besides being a good change to have on itself, this also paves the
way for switching to using malloc_simple in the SPL which cuts of
close to 4KiB of the SPL size.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 arch/arm/Kconfig                             | 1 +
 configs/A10-OLinuXino-Lime_defconfig         | 1 +
 configs/A10s-OLinuXino-M_defconfig           | 1 +
 configs/A13-OLinuXinoM_defconfig             | 1 +
 configs/A13-OLinuXino_defconfig              | 1 +
 configs/A20-OLinuXino-Lime2_defconfig        | 1 +
 configs/A20-OLinuXino-Lime_defconfig         | 1 +
 configs/A20-OLinuXino_MICRO_defconfig        | 1 +
 configs/A20-Olimex-SOM-EVB_defconfig         | 1 +
 configs/Ainol_AW1_defconfig                  | 1 +
 configs/Ampe_A76_defconfig                   | 1 +
 configs/Auxtek-T003_defconfig                | 1 +
 configs/Auxtek-T004_defconfig                | 1 +
 configs/Bananapi_defconfig                   | 1 +
 configs/Bananapro_defconfig                  | 1 +
 configs/CSQ_CS908_defconfig                  | 1 +
 configs/Chuwi_V7_CW0825_defconfig            | 1 +
 configs/Colombus_defconfig                   | 1 +
 configs/Cubieboard2_defconfig                | 1 +
 configs/Cubieboard_defconfig                 | 1 +
 configs/Cubietruck_defconfig                 | 1 +
 configs/Et_q8_v1_6_defconfig                 | 1 +
 configs/Hummingbird_A31_defconfig            | 1 +
 configs/Hyundai_A7HD_defconfig               | 1 +
 configs/Ippo_q8h_v1_2_a33_1024x600_defconfig | 1 +
 configs/Ippo_q8h_v1_2_defconfig              | 1 +
 configs/Ippo_q8h_v5_defconfig                | 1 +
 configs/Linksprite_pcDuino3_Nano_defconfig   | 1 +
 configs/Linksprite_pcDuino3_defconfig        | 1 +
 configs/Linksprite_pcDuino_defconfig         | 1 +
 configs/MK808C_defconfig                     | 1 +
 configs/MSI_Primo73_defconfig                | 1 +
 configs/MSI_Primo81_defconfig                | 1 +
 configs/Marsboard_A10_defconfig              | 1 +
 configs/Mele_A1000G_quad_defconfig           | 1 +
 configs/Mele_A1000_defconfig                 | 1 +
 configs/Mele_I7_defconfig                    | 1 +
 configs/Mele_M3_defconfig                    | 1 +
 configs/Mele_M5_defconfig                    | 1 +
 configs/Mele_M9_defconfig                    | 1 +
 configs/Merrii_A80_Optimus_defconfig         | 1 +
 configs/Mini-X_defconfig                     | 1 +
 configs/Orangepi_defconfig                   | 1 +
 configs/Orangepi_mini_defconfig              | 1 +
 configs/Sinlinx_SinA33_defconfig             | 1 +
 configs/TZX-Q8-713B7_defconfig               | 1 +
 configs/UTOO_P66_defconfig                   | 1 +
 configs/Wexler_TAB7200_defconfig             | 1 +
 configs/Wits_Pro_A20_DKT_defconfig           | 1 +
 configs/Wobo_i5_defconfig                    | 1 +
 configs/Yones_Toptech_BD1078_defconfig       | 1 +
 configs/ba10_tv_box_defconfig                | 1 +
 configs/forfun_q88db_defconfig               | 1 +
 configs/ga10h_v1_1_defconfig                 | 1 +
 configs/gt90h_v4_defconfig                   | 1 +
 configs/i12-tvbox_defconfig                  | 1 +
 configs/iNet_3F_defconfig                    | 1 +
 configs/iNet_3W_defconfig                    | 1 +
 configs/iNet_86VS_defconfig                  | 1 +
 configs/inet1_defconfig                      | 1 +
 configs/inet97fv2_defconfig                  | 1 +
 configs/inet98v_rev2_defconfig               | 1 +
 configs/inet9f_rev03_defconfig               | 1 +
 configs/jesurun_q5_defconfig                 | 1 +
 configs/mixtile_loftq_defconfig              | 1 +
 configs/mk802_a10s_defconfig                 | 1 +
 configs/mk802_defconfig                      | 1 +
 configs/mk802ii_defconfig                    | 1 +
 configs/pov_protab2_ips9_defconfig           | 1 +
 configs/q8_a13_tablet_defconfig              | 1 +
 configs/r7-tv-dongle_defconfig               | 1 +
 configs/sunxi_Gemei_G9_defconfig             | 1 +
 include/configs/sunxi-common.h               | 6 ++++++
 73 files changed, 78 insertions(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 57c48d5..a862a7a 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -518,6 +518,7 @@ config ARCH_SUNXI
 	select DM_USB
 	select OF_CONTROL
 	select OF_SEPARATE
+	select SPL_STACK_R
 	select USB
 	select USB_STORAGE
 	select USB_KEYBOARD
diff --git a/configs/A10-OLinuXino-Lime_defconfig b/configs/A10-OLinuXino-Lime_defconfig
index ee219f8..08f69d6 100644
--- a/configs/A10-OLinuXino-Lime_defconfig
+++ b/configs/A10-OLinuXino-Lime_defconfig
@@ -13,3 +13,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_EMAC,AHCI,SATAPWR=SUNXI_GPC(3)"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/A10s-OLinuXino-M_defconfig b/configs/A10s-OLinuXino-M_defconfig
index 7783c7d..fea71a0 100644
--- a/configs/A10s-OLinuXino-M_defconfig
+++ b/configs/A10s-OLinuXino-M_defconfig
@@ -14,3 +14,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP152_POWER,SUNXI_EMAC"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/A13-OLinuXinoM_defconfig b/configs/A13-OLinuXinoM_defconfig
index ccf35c7..8445143 100644
--- a/configs/A13-OLinuXinoM_defconfig
+++ b/configs/A13-OLinuXinoM_defconfig
@@ -18,3 +18,4 @@ CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=2"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/A13-OLinuXino_defconfig b/configs/A13-OLinuXino_defconfig
index 1f68d98..fcaa822 100644
--- a/configs/A13-OLinuXino_defconfig
+++ b/configs/A13-OLinuXino_defconfig
@@ -19,3 +19,4 @@ CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=2,AXP209_POWER"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/A20-OLinuXino-Lime2_defconfig b/configs/A20-OLinuXino-Lime2_defconfig
index c9d0f47..ed56de8 100644
--- a/configs/A20-OLinuXino-Lime2_defconfig
+++ b/configs/A20-OLinuXino-Lime2_defconfig
@@ -14,3 +14,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,RGMII,AHCI,SATAPWR=SUNXI_GPC(3
 # CONFIG_CMD_FPGA is not set
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/A20-OLinuXino-Lime_defconfig b/configs/A20-OLinuXino-Lime_defconfig
index 4a257b3..cc0a47c 100644
--- a/configs/A20-OLinuXino-Lime_defconfig
+++ b/configs/A20-OLinuXino-Lime_defconfig
@@ -12,3 +12,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,AHCI,SATAPWR=SUNXI_GPC(3)"
 # CONFIG_CMD_FPGA is not set
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/A20-OLinuXino_MICRO_defconfig b/configs/A20-OLinuXino_MICRO_defconfig
index a7f1395..5feee69 100644
--- a/configs/A20-OLinuXino_MICRO_defconfig
+++ b/configs/A20-OLinuXino_MICRO_defconfig
@@ -15,3 +15,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,AHCI,SATAPWR=SUNXI_GPB(8)"
 # CONFIG_CMD_FPGA is not set
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/A20-Olimex-SOM-EVB_defconfig b/configs/A20-Olimex-SOM-EVB_defconfig
index e8c3d18..ec0d1e5 100644
--- a/configs/A20-Olimex-SOM-EVB_defconfig
+++ b/configs/A20-Olimex-SOM-EVB_defconfig
@@ -14,3 +14,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,RGMII,AHCI,SATAPWR=SUNXI_GPC(3
 # CONFIG_CMD_FPGA is not set
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Ainol_AW1_defconfig b/configs/Ainol_AW1_defconfig
index 7c41aa8..70552e8 100644
--- a/configs/Ainol_AW1_defconfig
+++ b/configs/Ainol_AW1_defconfig
@@ -19,3 +19,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Ampe_A76_defconfig b/configs/Ampe_A76_defconfig
index 57ff52d..a02c8a35 100644
--- a/configs/Ampe_A76_defconfig
+++ b/configs/Ampe_A76_defconfig
@@ -20,3 +20,4 @@ CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=2,AXP209_POWER"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Auxtek-T003_defconfig b/configs/Auxtek-T003_defconfig
index b9692dc..769f66d 100644
--- a/configs/Auxtek-T003_defconfig
+++ b/configs/Auxtek-T003_defconfig
@@ -13,3 +13,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP152_POWER"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Auxtek-T004_defconfig b/configs/Auxtek-T004_defconfig
index c019176..1892f02 100644
--- a/configs/Auxtek-T004_defconfig
+++ b/configs/Auxtek-T004_defconfig
@@ -11,3 +11,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP152_POWER"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Bananapi_defconfig b/configs/Bananapi_defconfig
index 560295f..13d0377 100644
--- a/configs/Bananapi_defconfig
+++ b/configs/Bananapi_defconfig
@@ -13,3 +13,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,RGMII,MACPWR=SUNXI_GPH(23),AHC
 # CONFIG_CMD_FPGA is not set
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Bananapro_defconfig b/configs/Bananapro_defconfig
index 346db34..b2a3261 100644
--- a/configs/Bananapro_defconfig
+++ b/configs/Bananapro_defconfig
@@ -15,3 +15,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,RGMII,MACPWR=SUNXI_GPH(23),AHC
 # CONFIG_CMD_FPGA is not set
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/CSQ_CS908_defconfig b/configs/CSQ_CS908_defconfig
index 7c8eca8..a1453b4 100644
--- a/configs/CSQ_CS908_defconfig
+++ b/configs/CSQ_CS908_defconfig
@@ -16,3 +16,4 @@ CONFIG_AXP221_DLDO1_VOLT=3300
 CONFIG_AXP221_ALDO1_VOLT=3300
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Chuwi_V7_CW0825_defconfig b/configs/Chuwi_V7_CW0825_defconfig
index 7f1c4eb..5f4c87b 100644
--- a/configs/Chuwi_V7_CW0825_defconfig
+++ b/configs/Chuwi_V7_CW0825_defconfig
@@ -22,3 +22,4 @@ CONFIG_VIDEO_LCD_SPI_CS="PA0"
 CONFIG_VIDEO_LCD_SPI_SCLK="PA1"
 CONFIG_VIDEO_LCD_SPI_MOSI="PA2"
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Colombus_defconfig b/configs/Colombus_defconfig
index 35f644a..61d98a2 100644
--- a/configs/Colombus_defconfig
+++ b/configs/Colombus_defconfig
@@ -25,3 +25,4 @@ CONFIG_ETH_DESIGNWARE=y
 CONFIG_AXP221_ALDO1_VOLT=3300
 CONFIG_AXP221_ELDO3_VOLT=1800
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Cubieboard2_defconfig b/configs/Cubieboard2_defconfig
index 9bcaed1..50fe24e 100644
--- a/configs/Cubieboard2_defconfig
+++ b/configs/Cubieboard2_defconfig
@@ -12,3 +12,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,AHCI,SATAPWR=SUNXI_GPB(8)"
 # CONFIG_CMD_FPGA is not set
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Cubieboard_defconfig b/configs/Cubieboard_defconfig
index bbda5bf..eec0863 100644
--- a/configs/Cubieboard_defconfig
+++ b/configs/Cubieboard_defconfig
@@ -11,3 +11,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_EMAC,AHCI,SATAPWR=SUNXI_GPB(8)"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Cubietruck_defconfig b/configs/Cubietruck_defconfig
index e1b76ce..fdb78c1 100644
--- a/configs/Cubietruck_defconfig
+++ b/configs/Cubietruck_defconfig
@@ -14,3 +14,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,RGMII,AHCI,SATAPWR=SUNXI_GPH(1
 # CONFIG_CMD_FPGA is not set
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Et_q8_v1_6_defconfig b/configs/Et_q8_v1_6_defconfig
index 65b8e1a..055b495 100644
--- a/configs/Et_q8_v1_6_defconfig
+++ b/configs/Et_q8_v1_6_defconfig
@@ -21,3 +21,4 @@ CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=5"
 CONFIG_AXP221_DLDO1_VOLT=3300
 CONFIG_AXP221_ALDO1_VOLT=3000
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Hummingbird_A31_defconfig b/configs/Hummingbird_A31_defconfig
index 35c746c..2695eb8 100644
--- a/configs/Hummingbird_A31_defconfig
+++ b/configs/Hummingbird_A31_defconfig
@@ -16,3 +16,4 @@ CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII,MACPWR=SUNXI_GPA(21)"
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_AXP221_ALDO1_VOLT=3300
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Hyundai_A7HD_defconfig b/configs/Hyundai_A7HD_defconfig
index 9ef06a7..a571261 100644
--- a/configs/Hyundai_A7HD_defconfig
+++ b/configs/Hyundai_A7HD_defconfig
@@ -20,3 +20,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Ippo_q8h_v1_2_a33_1024x600_defconfig b/configs/Ippo_q8h_v1_2_a33_1024x600_defconfig
index 40ccf8f..4d607d6 100644
--- a/configs/Ippo_q8h_v1_2_a33_1024x600_defconfig
+++ b/configs/Ippo_q8h_v1_2_a33_1024x600_defconfig
@@ -22,3 +22,4 @@ CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=5"
 CONFIG_AXP221_DLDO1_VOLT=3300
 CONFIG_AXP221_ALDO1_VOLT=3000
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Ippo_q8h_v1_2_defconfig b/configs/Ippo_q8h_v1_2_defconfig
index 5b49c44..7d79bcb 100644
--- a/configs/Ippo_q8h_v1_2_defconfig
+++ b/configs/Ippo_q8h_v1_2_defconfig
@@ -22,3 +22,4 @@ CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=5"
 CONFIG_AXP221_DLDO1_VOLT=3300
 CONFIG_AXP221_ALDO1_VOLT=3000
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Ippo_q8h_v5_defconfig b/configs/Ippo_q8h_v5_defconfig
index 5316860..80ed134 100644
--- a/configs/Ippo_q8h_v5_defconfig
+++ b/configs/Ippo_q8h_v5_defconfig
@@ -22,3 +22,4 @@ CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=5"
 CONFIG_AXP221_DLDO1_VOLT=3300
 CONFIG_AXP221_ALDO1_VOLT=3000
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Linksprite_pcDuino3_Nano_defconfig b/configs/Linksprite_pcDuino3_Nano_defconfig
index 0b64b60..3259020 100644
--- a/configs/Linksprite_pcDuino3_Nano_defconfig
+++ b/configs/Linksprite_pcDuino3_Nano_defconfig
@@ -14,3 +14,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,RGMII,AHCI,SATAPWR=SUNXI_GPH(2
 # CONFIG_CMD_FPGA is not set
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Linksprite_pcDuino3_defconfig b/configs/Linksprite_pcDuino3_defconfig
index cced032..24c6bd6 100644
--- a/configs/Linksprite_pcDuino3_defconfig
+++ b/configs/Linksprite_pcDuino3_defconfig
@@ -12,3 +12,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,AHCI,SATAPWR=SUNXI_GPH(2)"
 # CONFIG_CMD_FPGA is not set
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Linksprite_pcDuino_defconfig b/configs/Linksprite_pcDuino_defconfig
index de44890..1ff3bfe 100644
--- a/configs/Linksprite_pcDuino_defconfig
+++ b/configs/Linksprite_pcDuino_defconfig
@@ -10,3 +10,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_EMAC"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/MK808C_defconfig b/configs/MK808C_defconfig
index 5e37485..49c5625 100644
--- a/configs/MK808C_defconfig
+++ b/configs/MK808C_defconfig
@@ -10,3 +10,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/MSI_Primo73_defconfig b/configs/MSI_Primo73_defconfig
index a60ce34..9dd1f55 100644
--- a/configs/MSI_Primo73_defconfig
+++ b/configs/MSI_Primo73_defconfig
@@ -14,3 +14,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
 # CONFIG_CMD_IMLS is not set
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/MSI_Primo81_defconfig b/configs/MSI_Primo81_defconfig
index 3b8e043..6969b3f 100644
--- a/configs/MSI_Primo81_defconfig
+++ b/configs/MSI_Primo81_defconfig
@@ -24,3 +24,4 @@ CONFIG_VIDEO_LCD_SPI_SCLK="PH10"
 CONFIG_VIDEO_LCD_SPI_MOSI="PH11"
 CONFIG_VIDEO_LCD_SPI_MISO="PH12"
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Marsboard_A10_defconfig b/configs/Marsboard_A10_defconfig
index 4933659..9f98ccc 100644
--- a/configs/Marsboard_A10_defconfig
+++ b/configs/Marsboard_A10_defconfig
@@ -9,3 +9,4 @@ CONFIG_SYS_EXTRA_OPTIONS="SUNXI_EMAC,AHCI"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Mele_A1000G_quad_defconfig b/configs/Mele_A1000G_quad_defconfig
index 5e31ef6..b02febb 100644
--- a/configs/Mele_A1000G_quad_defconfig
+++ b/configs/Mele_A1000G_quad_defconfig
@@ -18,3 +18,4 @@ CONFIG_AXP221_DLDO4_VOLT=3300
 CONFIG_AXP221_ALDO1_VOLT=3300
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Mele_A1000_defconfig b/configs/Mele_A1000_defconfig
index b983c8c..5905e4f 100644
--- a/configs/Mele_A1000_defconfig
+++ b/configs/Mele_A1000_defconfig
@@ -11,3 +11,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_EMAC,MACPWR=SUNXI_GPH(15),AHCI"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Mele_I7_defconfig b/configs/Mele_I7_defconfig
index 774a92f..23ea80b 100644
--- a/configs/Mele_I7_defconfig
+++ b/configs/Mele_I7_defconfig
@@ -17,3 +17,4 @@ CONFIG_AXP221_DLDO1_VOLT=3300
 CONFIG_AXP221_DLDO4_VOLT=3300
 CONFIG_AXP221_ALDO1_VOLT=3300
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Mele_M3_defconfig b/configs/Mele_M3_defconfig
index 5c9796a..498e8b7 100644
--- a/configs/Mele_M3_defconfig
+++ b/configs/Mele_M3_defconfig
@@ -15,3 +15,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC"
 # CONFIG_CMD_FPGA is not set
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Mele_M5_defconfig b/configs/Mele_M5_defconfig
index 0d1ba15..aa6070d 100644
--- a/configs/Mele_M5_defconfig
+++ b/configs/Mele_M5_defconfig
@@ -14,3 +14,4 @@ CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,AHCI,STATUSLED=234"
 # CONFIG_CMD_FPGA is not set
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Mele_M9_defconfig b/configs/Mele_M9_defconfig
index b52e3c2..716a9e4 100644
--- a/configs/Mele_M9_defconfig
+++ b/configs/Mele_M9_defconfig
@@ -17,3 +17,4 @@ CONFIG_AXP221_DLDO1_VOLT=3300
 CONFIG_AXP221_DLDO4_VOLT=3300
 CONFIG_AXP221_ALDO1_VOLT=3300
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Merrii_A80_Optimus_defconfig b/configs/Merrii_A80_Optimus_defconfig
index 53e023a..acfbd21 100644
--- a/configs/Merrii_A80_Optimus_defconfig
+++ b/configs/Merrii_A80_Optimus_defconfig
@@ -11,3 +11,4 @@ CONFIG_DEFAULT_DEVICE_TREE="sun9i-a80-optimus"
 # CONFIG_CMD_IMLS is not set
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
+CONFIG_SPL_STACK_R_ADDR=0x2fe00000
diff --git a/configs/Mini-X_defconfig b/configs/Mini-X_defconfig
index 31d6217..755b2ec 100644
--- a/configs/Mini-X_defconfig
+++ b/configs/Mini-X_defconfig
@@ -12,3 +12,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Orangepi_defconfig b/configs/Orangepi_defconfig
index d67bb90..4966aff 100644
--- a/configs/Orangepi_defconfig
+++ b/configs/Orangepi_defconfig
@@ -16,3 +16,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,RGMII,MACPWR=SUNXI_GPH(23),AHC
 # CONFIG_CMD_FPGA is not set
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Orangepi_mini_defconfig b/configs/Orangepi_mini_defconfig
index 71d236b..af45541 100644
--- a/configs/Orangepi_mini_defconfig
+++ b/configs/Orangepi_mini_defconfig
@@ -18,3 +18,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,RGMII,MACPWR=SUNXI_GPH(23),AHC
 # CONFIG_CMD_FPGA is not set
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Sinlinx_SinA33_defconfig b/configs/Sinlinx_SinA33_defconfig
index 720f3dc..2167665 100644
--- a/configs/Sinlinx_SinA33_defconfig
+++ b/configs/Sinlinx_SinA33_defconfig
@@ -10,3 +10,4 @@ CONFIG_SPL=y
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_AXP221_ALDO1_VOLT=3000
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/TZX-Q8-713B7_defconfig b/configs/TZX-Q8-713B7_defconfig
index f5e3574..a9e6257 100644
--- a/configs/TZX-Q8-713B7_defconfig
+++ b/configs/TZX-Q8-713B7_defconfig
@@ -19,3 +19,4 @@ CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=2,AXP209_POWER"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/UTOO_P66_defconfig b/configs/UTOO_P66_defconfig
index 5417814..8cad8bb 100644
--- a/configs/UTOO_P66_defconfig
+++ b/configs/UTOO_P66_defconfig
@@ -26,3 +26,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
 # CONFIG_CMD_FPGA is not set
 # CONFIG_REQUIRE_SERIAL_CONSOLE is not set
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Wexler_TAB7200_defconfig b/configs/Wexler_TAB7200_defconfig
index 02504f9..2db35bb 100644
--- a/configs/Wexler_TAB7200_defconfig
+++ b/configs/Wexler_TAB7200_defconfig
@@ -19,3 +19,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Wits_Pro_A20_DKT_defconfig b/configs/Wits_Pro_A20_DKT_defconfig
index 66b51bc..81bbfda 100644
--- a/configs/Wits_Pro_A20_DKT_defconfig
+++ b/configs/Wits_Pro_A20_DKT_defconfig
@@ -17,3 +17,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,RGMII,AHCI"
 # CONFIG_CMD_FPGA is not set
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Wobo_i5_defconfig b/configs/Wobo_i5_defconfig
index 206fd48..7e988a5 100644
--- a/configs/Wobo_i5_defconfig
+++ b/configs/Wobo_i5_defconfig
@@ -12,3 +12,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/Yones_Toptech_BD1078_defconfig b/configs/Yones_Toptech_BD1078_defconfig
index e26816c..ae50556 100644
--- a/configs/Yones_Toptech_BD1078_defconfig
+++ b/configs/Yones_Toptech_BD1078_defconfig
@@ -24,3 +24,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/ba10_tv_box_defconfig b/configs/ba10_tv_box_defconfig
index 104d53d..d85b891 100644
--- a/configs/ba10_tv_box_defconfig
+++ b/configs/ba10_tv_box_defconfig
@@ -15,3 +15,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_EMAC"
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/forfun_q88db_defconfig b/configs/forfun_q88db_defconfig
index 30e0937..de5037e 100644
--- a/configs/forfun_q88db_defconfig
+++ b/configs/forfun_q88db_defconfig
@@ -18,3 +18,4 @@ CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=2,AXP209_POWER"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/ga10h_v1_1_defconfig b/configs/ga10h_v1_1_defconfig
index 417a89c..aa1e747 100644
--- a/configs/ga10h_v1_1_defconfig
+++ b/configs/ga10h_v1_1_defconfig
@@ -25,3 +25,4 @@ CONFIG_AXP221_DLDO1_VOLT=3300
 CONFIG_AXP221_ALDO1_VOLT=3000
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/gt90h_v4_defconfig b/configs/gt90h_v4_defconfig
index 3b72dc2..e6bd733 100644
--- a/configs/gt90h_v4_defconfig
+++ b/configs/gt90h_v4_defconfig
@@ -24,3 +24,4 @@ CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=5"
 CONFIG_AXP221_DCDC2_VOLT=1100
 CONFIG_AXP221_DLDO1_VOLT=3300
 CONFIG_AXP221_ALDO1_VOLT=3000
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/i12-tvbox_defconfig b/configs/i12-tvbox_defconfig
index d4d9524..3646bd6 100644
--- a/configs/i12-tvbox_defconfig
+++ b/configs/i12-tvbox_defconfig
@@ -12,3 +12,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,MACPWR=SUNXI_GPH(21)"
 # CONFIG_CMD_FPGA is not set
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/iNet_3F_defconfig b/configs/iNet_3F_defconfig
index 211cb86..f792eb3 100644
--- a/configs/iNet_3F_defconfig
+++ b/configs/iNet_3F_defconfig
@@ -19,3 +19,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/iNet_3W_defconfig b/configs/iNet_3W_defconfig
index 35f08e5..2447fdb 100644
--- a/configs/iNet_3W_defconfig
+++ b/configs/iNet_3W_defconfig
@@ -19,3 +19,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/iNet_86VS_defconfig b/configs/iNet_86VS_defconfig
index bb8d080..c34b1cd 100644
--- a/configs/iNet_86VS_defconfig
+++ b/configs/iNet_86VS_defconfig
@@ -18,3 +18,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/inet1_defconfig b/configs/inet1_defconfig
index b2ba497..399a976 100644
--- a/configs/inet1_defconfig
+++ b/configs/inet1_defconfig
@@ -20,3 +20,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/inet97fv2_defconfig b/configs/inet97fv2_defconfig
index d7ddee1..5aeddbe 100644
--- a/configs/inet97fv2_defconfig
+++ b/configs/inet97fv2_defconfig
@@ -18,3 +18,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
 # CONFIG_CMD_IMLS is not set
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/inet98v_rev2_defconfig b/configs/inet98v_rev2_defconfig
index c23245a..6b2284c 100644
--- a/configs/inet98v_rev2_defconfig
+++ b/configs/inet98v_rev2_defconfig
@@ -20,3 +20,4 @@ CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=2,AXP209_POWER"
 # CONFIG_CMD_IMLS is not set
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/inet9f_rev03_defconfig b/configs/inet9f_rev03_defconfig
index fdfb02a..fe2b350 100644
--- a/configs/inet9f_rev03_defconfig
+++ b/configs/inet9f_rev03_defconfig
@@ -18,3 +18,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
 # CONFIG_CMD_IMLS is not set
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/jesurun_q5_defconfig b/configs/jesurun_q5_defconfig
index 46c38e5..889696a 100644
--- a/configs/jesurun_q5_defconfig
+++ b/configs/jesurun_q5_defconfig
@@ -13,3 +13,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_EMAC,MACPWR=SUNXI_GPH(19)"
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_HOST=y
 CONFIG_USB0_VBUS_PIN="PB9"
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/mixtile_loftq_defconfig b/configs/mixtile_loftq_defconfig
index 26fc4ce..cc8a024 100644
--- a/configs/mixtile_loftq_defconfig
+++ b/configs/mixtile_loftq_defconfig
@@ -15,3 +15,4 @@ CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII,MACPWR=SUNXI_GPA(21)"
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_AXP221_ALDO1_VOLT=3300
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/mk802_a10s_defconfig b/configs/mk802_a10s_defconfig
index db437f0..b0584b5 100644
--- a/configs/mk802_a10s_defconfig
+++ b/configs/mk802_a10s_defconfig
@@ -12,3 +12,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP152_POWER"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/mk802_defconfig b/configs/mk802_defconfig
index 68b2c5e..c2136b7 100644
--- a/configs/mk802_defconfig
+++ b/configs/mk802_defconfig
@@ -10,3 +10,4 @@ CONFIG_SYS_EXTRA_OPTIONS="USB_EHCI"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/mk802ii_defconfig b/configs/mk802ii_defconfig
index d3cb664..5cf742c 100644
--- a/configs/mk802ii_defconfig
+++ b/configs/mk802ii_defconfig
@@ -9,3 +9,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/pov_protab2_ips9_defconfig b/configs/pov_protab2_ips9_defconfig
index 3107f31..b28eb4d 100644
--- a/configs/pov_protab2_ips9_defconfig
+++ b/configs/pov_protab2_ips9_defconfig
@@ -19,3 +19,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/q8_a13_tablet_defconfig b/configs/q8_a13_tablet_defconfig
index 2c61f51..16b2d51 100644
--- a/configs/q8_a13_tablet_defconfig
+++ b/configs/q8_a13_tablet_defconfig
@@ -20,3 +20,4 @@ CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=2,AXP209_POWER"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_MUSB_HOST=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/r7-tv-dongle_defconfig b/configs/r7-tv-dongle_defconfig
index 62c58fc..77c9170 100644
--- a/configs/r7-tv-dongle_defconfig
+++ b/configs/r7-tv-dongle_defconfig
@@ -11,3 +11,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP152_POWER"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/configs/sunxi_Gemei_G9_defconfig b/configs/sunxi_Gemei_G9_defconfig
index d0f987c..66c763e 100644
--- a/configs/sunxi_Gemei_G9_defconfig
+++ b/configs/sunxi_Gemei_G9_defconfig
@@ -16,3 +16,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SPL_STACK_R_ADDR=0x4fe00000
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 7c1507b..6aa1bf2 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -73,6 +73,9 @@
 #define CONFIG_SYS_LOAD_ADDR		0x22000000 /* default load address */
 #define CONFIG_SYS_TEXT_BASE		0x2a000000
 #define CONFIG_PRE_CON_BUF_ADDR		0x2f000000
+/* Note this is primarily set through Kconfig, we redefine it here so that
+ * we get warnings if the Kconfig value mismatches. */
+#define CONFIG_SPL_STACK_R_ADDR		0x2fe00000
 #define CONFIG_SYS_SPL_MALLOC_START	0x2ff00000
 #define CONFIG_SPL_BSS_START_ADDR	0x2ff80000
 #else
@@ -81,6 +84,9 @@
 #define CONFIG_SYS_LOAD_ADDR		0x42000000 /* default load address */
 #define CONFIG_SYS_TEXT_BASE		0x4a000000
 #define CONFIG_PRE_CON_BUF_ADDR		0x4f000000
+/* Note this is primarily set through Kconfig, we redefine it here so that
+ * we get warnings if the Kconfig value mismatches. */
+#define CONFIG_SPL_STACK_R_ADDR		0x4fe00000
 #define CONFIG_SYS_SPL_MALLOC_START	0x4ff00000
 #define CONFIG_SPL_BSS_START_ADDR	0x4ff80000
 #endif
-- 
2.4.3

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

* [U-Boot] [PATCH 7/7] sunxi: Switch to using malloc_simple for the spl
  2015-09-13 15:42 [U-Boot] [PATCH 0/7] malloc_simple: Add support for switching to DRAM heap Hans de Goede
                   ` (5 preceding siblings ...)
  2015-09-13 15:42 ` [U-Boot] [PATCH 6/7] sunxi: Enable CONFIG_SPL_STACK_R Hans de Goede
@ 2015-09-13 15:42 ` Hans de Goede
  2015-09-13 16:33   ` Ian Campbell
  6 siblings, 1 reply; 21+ messages in thread
From: Hans de Goede @ 2015-09-13 15:42 UTC (permalink / raw)
  To: u-boot

common/dlmalloc.c is quite big, both in .text and .data usage. E.g. for a
Mele_M9 sun6i board build this reduces .text from 0x4214 to 0x3b94 bytes,
and .data from 0x54c to 0x144 bytes.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 arch/arm/Kconfig               | 1 +
 include/configs/sunxi-common.h | 3 ---
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a862a7a..f53c41f 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -518,6 +518,7 @@ config ARCH_SUNXI
 	select DM_USB
 	select OF_CONTROL
 	select OF_SEPARATE
+	select SPL_MALLOC_SIMPLE
 	select SPL_STACK_R
 	select USB
 	select USB_STORAGE
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 6aa1bf2..9ca642a 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -76,7 +76,6 @@
 /* Note this is primarily set through Kconfig, we redefine it here so that
  * we get warnings if the Kconfig value mismatches. */
 #define CONFIG_SPL_STACK_R_ADDR		0x2fe00000
-#define CONFIG_SYS_SPL_MALLOC_START	0x2ff00000
 #define CONFIG_SPL_BSS_START_ADDR	0x2ff80000
 #else
 #define SDRAM_OFFSET(x) 0x4##x
@@ -87,12 +86,10 @@
 /* Note this is primarily set through Kconfig, we redefine it here so that
  * we get warnings if the Kconfig value mismatches. */
 #define CONFIG_SPL_STACK_R_ADDR		0x4fe00000
-#define CONFIG_SYS_SPL_MALLOC_START	0x4ff00000
 #define CONFIG_SPL_BSS_START_ADDR	0x4ff80000
 #endif
 
 #define CONFIG_SPL_BSS_MAX_SIZE		0x00080000 /* 512 KiB */
-#define CONFIG_SYS_SPL_MALLOC_SIZE	0x00080000 /* 512 KiB */
 
 #ifdef CONFIG_MACH_SUN9I
 /*
-- 
2.4.3

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

* [U-Boot] [PATCH 5/7] sunxi: Simplify spl board_init_f function
  2015-09-13 15:42 ` [U-Boot] [PATCH 5/7] sunxi: Simplify spl board_init_f function Hans de Goede
@ 2015-09-13 16:27   ` Ian Campbell
  0 siblings, 0 replies; 21+ messages in thread
From: Ian Campbell @ 2015-09-13 16:27 UTC (permalink / raw)
  To: u-boot

On Sun, 2015-09-13 at 17:42 +0200, Hans de Goede wrote:
> crt0.S will both memset the bss sectioan and call board_init_r for
> us,
> so there is no need to do either ourselves.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Acked-by: Ian Campbell <ijc@hellion.org.uk>

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

* [U-Boot] [PATCH 6/7] sunxi: Enable CONFIG_SPL_STACK_R
  2015-09-13 15:42 ` [U-Boot] [PATCH 6/7] sunxi: Enable CONFIG_SPL_STACK_R Hans de Goede
@ 2015-09-13 16:33   ` Ian Campbell
  2015-09-13 16:38     ` Hans de Goede
  0 siblings, 1 reply; 21+ messages in thread
From: Ian Campbell @ 2015-09-13 16:33 UTC (permalink / raw)
  To: u-boot

On Sun, 2015-09-13 at 17:42 +0200, Hans de Goede wrote:
> index 7c1507b..6aa1bf2 100644
> --- a/include/configs/sunxi-common.h
> +++ b/include/configs/sunxi-common.h
> @@ -73,6 +73,9 @@
>  #define CONFIG_SYS_LOAD_ADDR		0x22000000 /* default
> load address */
>  #define CONFIG_SYS_TEXT_BASE		0x2a000000
>  #define CONFIG_PRE_CON_BUF_ADDR		0x2f000000
> +/* Note this is primarily set through Kconfig, we redefine it here so that
> + * we get warnings if the Kconfig value mismatches. */

Mismatches with what? Why can't we just use the Kconfig supplied value
throughout?

If there is a piece of code somewhere which cannot use the Kconfig
value for some reason and is therefore hardcoded then using
BUILD_BUG_ON would be best IMHO. There should also be a comment next to
the B_B_ON explaining why that code cannot use the Kconfig value.

> +#define CONFIG_SPL_STACK_R_ADDR		0x2fe00000

Ian.

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

* [U-Boot] [PATCH 7/7] sunxi: Switch to using malloc_simple for the spl
  2015-09-13 15:42 ` [U-Boot] [PATCH 7/7] sunxi: Switch to using malloc_simple for the spl Hans de Goede
@ 2015-09-13 16:33   ` Ian Campbell
  0 siblings, 0 replies; 21+ messages in thread
From: Ian Campbell @ 2015-09-13 16:33 UTC (permalink / raw)
  To: u-boot

On Sun, 2015-09-13 at 17:42 +0200, Hans de Goede wrote:
> common/dlmalloc.c is quite big, both in .text and .data usage. E.g.
> for a
> Mele_M9 sun6i board build this reduces .text from 0x4214 to 0x3b94
> bytes,
> and .data from 0x54c to 0x144 bytes.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Acked-by: Ian Campbell <ijc@hellion.org.uk>

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

* [U-Boot] [PATCH 6/7] sunxi: Enable CONFIG_SPL_STACK_R
  2015-09-13 16:33   ` Ian Campbell
@ 2015-09-13 16:38     ` Hans de Goede
  2015-09-13 18:50       ` Ian Campbell
  0 siblings, 1 reply; 21+ messages in thread
From: Hans de Goede @ 2015-09-13 16:38 UTC (permalink / raw)
  To: u-boot

Hi,

On 13-09-15 18:33, Ian Campbell wrote:
> On Sun, 2015-09-13 at 17:42 +0200, Hans de Goede wrote:
>> index 7c1507b..6aa1bf2 100644
>> --- a/include/configs/sunxi-common.h
>> +++ b/include/configs/sunxi-common.h
>> @@ -73,6 +73,9 @@
>>   #define CONFIG_SYS_LOAD_ADDR		0x22000000 /* default
>> load address */
>>   #define CONFIG_SYS_TEXT_BASE		0x2a000000
>>   #define CONFIG_PRE_CON_BUF_ADDR		0x2f000000
>> +/* Note this is primarily set through Kconfig, we redefine it here so that
>> + * we get warnings if the Kconfig value mismatches. */
>
> Mismatches with what? Why can't we just use the Kconfig supplied value
> throughout?

Mismatches with the value defined here in sunxi-common.h, sunxi-common.h
lists all other spl memory addresses right in this block, making it
possible to quickly see what goes there. If someone ever decides to tweak
the layout, then they will likely forget the single value which is set
in the defconfig-s, but they will (presumably) update the copy in
sunxi-common.h, as that is sitting there right next to the others.

If this happens then the compiler will give a warning (for each C-file)
that CONFIG_SPL_STACK_R_ADDR is being redefined.

So functionality wise this does nothing, leaving it out will result
in an identical build. It is just there to help us poor humans to
not forger to update the value in the defconfig files if we ever
decide to tweak the SPL memory layout.

Regards,

Hans

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

* [U-Boot] [PATCH 6/7] sunxi: Enable CONFIG_SPL_STACK_R
  2015-09-13 16:38     ` Hans de Goede
@ 2015-09-13 18:50       ` Ian Campbell
  2015-09-13 18:51         ` Hans de Goede
  0 siblings, 1 reply; 21+ messages in thread
From: Ian Campbell @ 2015-09-13 18:50 UTC (permalink / raw)
  To: u-boot

On Sun, 2015-09-13 at 18:38 +0200, Hans de Goede wrote:
> Hi,
> 
> On 13-09-15 18:33, Ian Campbell wrote:
> > On Sun, 2015-09-13 at 17:42 +0200, Hans de Goede wrote:
> >> index 7c1507b..6aa1bf2 100644
> >> --- a/include/configs/sunxi-common.h
> >> +++ b/include/configs/sunxi-common.h
> >> @@ -73,6 +73,9 @@
> >>   #define CONFIG_SYS_LOAD_ADDR		0x22000000 /*
> default
> >> load address */
> >>   #define CONFIG_SYS_TEXT_BASE		0x2a000000
> >>   #define CONFIG_PRE_CON_BUF_ADDR		0x2f000000
> >> +/* Note this is primarily set through Kconfig, we redefine it
> here so that
> >> + * we get warnings if the Kconfig value mismatches. */
> >
> > Mismatches with what? Why can't we just use the Kconfig supplied
> value
> > throughout?
> 
> Mismatches with the value defined here in sunxi-common.h, sunxi
> -common.h
> lists all other spl memory addresses right in this block, making it
> possible to quickly see what goes there. If someone ever decides to
> tweak
> the layout, then they will likely forget the single value which is
> set
> in the defconfig-s, but they will (presumably) update the copy in
> sunxi-common.h, as that is sitting there right next to the others.
> 
> If this happens then the compiler will give a warning (for each C
> -file)
> that CONFIG_SPL_STACK_R_ADDR is being redefined.
> 
> So functionality wise this does nothing, leaving it out will result
> in an identical build. It is just there to help us poor humans to
> not forger to update the value in the defconfig files if we ever
> decide to tweak the SPL memory layout.

Got it, in which case I would drop the "primarily" from the comment,
since that suggests it is defined "secondarily" here, when really it is
just for documentation (with a clever trick to stop the docs getting
out of date).

Maybe even:

/* Note SPL_STACK_R_ADDR is set through Kconfig, we include it here 
 * since it needs to fit in with the other values. By also #defining it
 * we get warnings if the Kconfig value mismatches. */

???

(And presumably this all gets less mad as more and more stuff moves to
Kconfig...)

Ian.

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

* [U-Boot] [PATCH 6/7] sunxi: Enable CONFIG_SPL_STACK_R
  2015-09-13 18:50       ` Ian Campbell
@ 2015-09-13 18:51         ` Hans de Goede
  2015-09-14  6:00           ` Ian Campbell
  0 siblings, 1 reply; 21+ messages in thread
From: Hans de Goede @ 2015-09-13 18:51 UTC (permalink / raw)
  To: u-boot

Hi,

On 13-09-15 20:50, Ian Campbell wrote:
> On Sun, 2015-09-13 at 18:38 +0200, Hans de Goede wrote:
>> Hi,
>>
>> On 13-09-15 18:33, Ian Campbell wrote:
>>> On Sun, 2015-09-13 at 17:42 +0200, Hans de Goede wrote:
>>>> index 7c1507b..6aa1bf2 100644
>>>> --- a/include/configs/sunxi-common.h
>>>> +++ b/include/configs/sunxi-common.h
>>>> @@ -73,6 +73,9 @@
>>>>    #define CONFIG_SYS_LOAD_ADDR		0x22000000 /*
>> default
>>>> load address */
>>>>    #define CONFIG_SYS_TEXT_BASE		0x2a000000
>>>>    #define CONFIG_PRE_CON_BUF_ADDR		0x2f000000
>>>> +/* Note this is primarily set through Kconfig, we redefine it
>> here so that
>>>> + * we get warnings if the Kconfig value mismatches. */
>>>
>>> Mismatches with what? Why can't we just use the Kconfig supplied
>> value
>>> throughout?
>>
>> Mismatches with the value defined here in sunxi-common.h, sunxi
>> -common.h
>> lists all other spl memory addresses right in this block, making it
>> possible to quickly see what goes there. If someone ever decides to
>> tweak
>> the layout, then they will likely forget the single value which is
>> set
>> in the defconfig-s, but they will (presumably) update the copy in
>> sunxi-common.h, as that is sitting there right next to the others.
>>
>> If this happens then the compiler will give a warning (for each C
>> -file)
>> that CONFIG_SPL_STACK_R_ADDR is being redefined.
>>
>> So functionality wise this does nothing, leaving it out will result
>> in an identical build. It is just there to help us poor humans to
>> not forger to update the value in the defconfig files if we ever
>> decide to tweak the SPL memory layout.
>
> Got it, in which case I would drop the "primarily" from the comment,
> since that suggests it is defined "secondarily" here, when really it is
> just for documentation (with a clever trick to stop the docs getting
> out of date).
>
> Maybe even:
>
> /* Note SPL_STACK_R_ADDR is set through Kconfig, we include it here
>   * since it needs to fit in with the other values. By also #defining it
>   * we get warnings if the Kconfig value mismatches. */

That works for me, I'll replace my comment with the one you've suggested.

Regards,

Hans

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

* [U-Boot] [PATCH 6/7] sunxi: Enable CONFIG_SPL_STACK_R
  2015-09-13 18:51         ` Hans de Goede
@ 2015-09-14  6:00           ` Ian Campbell
  0 siblings, 0 replies; 21+ messages in thread
From: Ian Campbell @ 2015-09-14  6:00 UTC (permalink / raw)
  To: u-boot

On Sun, 2015-09-13 at 20:51 +0200, Hans de Goede wrote:
> Hi,
> 
> On 13-09-15 20:50, Ian Campbell wrote:

> > Maybe even:
> >
> > /* Note SPL_STACK_R_ADDR is set through Kconfig, we include it here
> >   * since it needs to fit in with the other values. By also #defining it
> >   * we get warnings if the Kconfig value mismatches. */
> 
> That works for me, I'll replace my comment with the one you've suggested.

That version: Acked-by: Ian Campbell <ijc@hellion.org.uk>

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

* [U-Boot] [PATCH 1/7] spl: spl_relocate_stack_gd: Do not unnecessarily clear bss
  2015-09-13 15:42 ` [U-Boot] [PATCH 1/7] spl: spl_relocate_stack_gd: Do not unnecessarily clear bss Hans de Goede
@ 2015-09-22  4:00   ` Simon Glass
  0 siblings, 0 replies; 21+ messages in thread
From: Simon Glass @ 2015-09-22  4:00 UTC (permalink / raw)
  To: u-boot

Hi Hans,

On 13 September 2015 at 09:42, Hans de Goede <hdegoede@redhat.com> wrote:
>
> spl_relocate_stack_gd only gets called from arch/arm/lib/crt0.S which
> clears the bss directly after calling it, so there is no need to clear
> it from spl_relocate_stack_gd.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  common/spl/spl.c | 3 ---
>  1 file changed, 3 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

I think it makes sense to move the BSS clear to C, but that would be
separate from your patch. Yes we should remove this duplication.

See also this:

http://patchwork.ozlabs.org/patch/512030/

>
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index a5892d7..b09a626 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -347,9 +347,6 @@ ulong spl_relocate_stack_gd(void)
>         memcpy(new_gd, (void *)gd, sizeof(gd_t));
>         gd = new_gd;
>
> -       /* Clear the BSS. */
> -       memset(__bss_start, 0, __bss_end - __bss_start);
> -
>         return ptr;
>  #else
>         return 0;
> --
> 2.4.3
>

Regards,
Simon

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

* [U-Boot] [PATCH 2/7] malloc_simple: Fix malloc_ptr calculation
  2015-09-13 15:42 ` [U-Boot] [PATCH 2/7] malloc_simple: Fix malloc_ptr calculation Hans de Goede
@ 2015-09-22  4:00   ` Simon Glass
  0 siblings, 0 replies; 21+ messages in thread
From: Simon Glass @ 2015-09-22  4:00 UTC (permalink / raw)
  To: u-boot

On 13 September 2015 at 09:42, Hans de Goede <hdegoede@redhat.com> wrote:
> From: Philipp Rosenberger <ilu@linutronix.de>
>
> The gd->malloc_ptr and the gd->malloc_limit are offsets to gd->malloc_base.
> But the addr variable contains the absolute address. The new_ptr must be:
> addr + bytes - gd->malloc_base.
>
> Signed-off-by: Philipp Rosenberger <ilu@linutronix.de>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  common/malloc_simple.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Eek! Nice to find this one.

Reviewed-by: Simon Glass <sjg@chromium.org>

>
> diff --git a/common/malloc_simple.c b/common/malloc_simple.c
> index 134e059..c745863 100644
> --- a/common/malloc_simple.c
> +++ b/common/malloc_simple.c
> @@ -32,7 +32,7 @@ void *memalign_simple(size_t align, size_t bytes)
>         void *ptr;
>
>         addr = ALIGN(gd->malloc_base + gd->malloc_ptr, align);
> -       new_ptr = addr + bytes;
> +       new_ptr = addr + bytes - gd->malloc_base;
>         if (new_ptr > gd->malloc_limit)
>                 return NULL;
>         ptr = map_sysmem(addr, bytes);
> --
> 2.4.3
>

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

* [U-Boot] [PATCH 3/7] malloc_simple: Add Kconfig option for using only malloc_simple in the SPL
  2015-09-13 15:42 ` [U-Boot] [PATCH 3/7] malloc_simple: Add Kconfig option for using only malloc_simple in the SPL Hans de Goede
@ 2015-09-22  4:00   ` Simon Glass
  2015-09-22  9:38     ` Hans de Goede
  0 siblings, 1 reply; 21+ messages in thread
From: Simon Glass @ 2015-09-22  4:00 UTC (permalink / raw)
  To: u-boot

Hi Hans,

On 13 September 2015 at 09:42, Hans de Goede <hdegoede@redhat.com> wrote:
> common/dlmalloc.c is quite big, both in .text and .data usage, therefor
> on some boards the SPL is build to use only malloc_simple.c and not the
> dlmalloc.c code. This is done in various include/configs/foo.h with the
> following construct:
>

Was there a '#' at the start of this missing line?

> This commit introduces a SPL_MALLOC_SIMPLE Kconfig bool which allows
> selecting this functionality through Kconfig instead.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  Kconfig                | 10 ++++++++++
>  common/malloc_simple.c |  3 ++-
>  include/_exports.h     |  3 ++-
>  include/exports.h      |  3 ++-
>  include/malloc.h       |  3 ++-
>  5 files changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/Kconfig b/Kconfig
> index 05a34f7..0ae4fab 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -114,6 +114,16 @@ config SPL
>         help
>           If you want to build SPL as well as the normal image, say Y.
>
> +config SPL_MALLOC_SIMPLE

If you made it SPL_SYS_MALLOC_SIMPLE...

> +       bool
> +       depends on SPL
> +       prompt "Only use malloc_simple functions in the spl"
> +       help
> +         Say Y here to only use the *_simple malloc functions from
> +         malloc_simple.c, rather then using the versions from dlmalloc.c
> +         this will make the SPL binary smaller at the cost of more heap
> +         usage as the *_simple malloc functions do not re-use free-ed mem.
> +
>  config SPL_STACK_R
>         depends on SPL
>         bool "Enable SDRAM location for SPL stack"
> diff --git a/common/malloc_simple.c b/common/malloc_simple.c
> index c745863..e9c1eaa 100644
> --- a/common/malloc_simple.c
> +++ b/common/malloc_simple.c
> @@ -40,7 +40,8 @@ void *memalign_simple(size_t align, size_t bytes)
>         return ptr;
>  }
>
> -#ifdef CONFIG_SYS_MALLOC_SIMPLE
> +#if (defined CONFIG_SPL_BUILD && defined CONFIG_SPL_MALLOC_SIMPLE) || \
> +    (defined CONFIG_SYS_MALLOC_SIMPLE)

then I think this could become:

#if CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)

>  void *calloc(size_t nmemb, size_t elem_size)
>  {
>         size_t size = nmemb * elem_size;
> diff --git a/include/_exports.h b/include/_exports.h
> index 74a882a..f811c5d 100644
> --- a/include/_exports.h
> +++ b/include/_exports.h
> @@ -23,7 +23,8 @@
>         EXPORT_FUNC(dummy, void, free_hdlr, void)
>  #endif
>         EXPORT_FUNC(malloc, void *, malloc, size_t)
> -#ifndef CONFIG_SYS_MALLOC_SIMPLE
> +#if !(defined CONFIG_SPL_BUILD && defined CONFIG_SPL_MALLOC_SIMPLE) && \
> +    !(defined CONFIG_SYS_MALLOC_SIMPLE)
>         EXPORT_FUNC(free, void, free, void *)
>  #endif
>         EXPORT_FUNC(udelay, void, udelay, unsigned long)
> diff --git a/include/exports.h b/include/exports.h
> index a3e0469..8171b31 100644
> --- a/include/exports.h
> +++ b/include/exports.h
> @@ -19,7 +19,8 @@ int printf(const char* fmt, ...);
>  void install_hdlr(int, interrupt_handler_t, void*);
>  void free_hdlr(int);
>  void *malloc(size_t);
> -#ifndef CONFIG_SYS_MALLOC_SIMPLE
> +#if !(defined CONFIG_SPL_BUILD && defined CONFIG_SPL_MALLOC_SIMPLE) && \
> +    !(defined CONFIG_SYS_MALLOC_SIMPLE)
>  void free(void*);
>  #endif
>  void __udelay(unsigned long);
> diff --git a/include/malloc.h b/include/malloc.h
> index f4da9e6..e5592fc 100644
> --- a/include/malloc.h
> +++ b/include/malloc.h
> @@ -872,7 +872,8 @@ extern Void_t*     sbrk();
>
>  #else
>
> -#ifdef CONFIG_SYS_MALLOC_SIMPLE
> +#if (defined CONFIG_SPL_BUILD && defined CONFIG_SPL_MALLOC_SIMPLE) || \
> +    (defined CONFIG_SYS_MALLOC_SIMPLE)
>  #define malloc malloc_simple
>  #define realloc realloc_simple
>  #define memalign memalign_simple
> --
> 2.4.3
>

Regards,
Simon

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

* [U-Boot] [PATCH 4/7] malloc_simple: Add support for switching to DRAM heap
  2015-09-13 15:42 ` [U-Boot] [PATCH 4/7] malloc_simple: Add support for switching to DRAM heap Hans de Goede
@ 2015-09-22  4:00   ` Simon Glass
  2015-09-22  9:52     ` Hans de Goede
  0 siblings, 1 reply; 21+ messages in thread
From: Simon Glass @ 2015-09-22  4:00 UTC (permalink / raw)
  To: u-boot

Hi Hans,

On 13 September 2015 at 09:42, Hans de Goede <hdegoede@redhat.com> wrote:
> malloc_simple uses a part of the stack as heap, initially it uses
> SYS_MALLOC_F_LEN bytes which typically is quite small as the initial
> stacks sits in SRAM and we do not have that much SRAM to work with.
>
> When DRAM becomes available we may switch the stack from SRAM to DRAM
> to give use more room. This commit adds support for also switching to
> a new bigger malloc_simple heap located in the new stack.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  Kconfig          | 10 ++++++++++
>  common/spl/spl.c |  9 +++++++++
>  2 files changed, 19 insertions(+)
>
> diff --git a/Kconfig b/Kconfig
> index 0ae4fab..86088bc 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -142,6 +142,16 @@ config SPL_STACK_R_ADDR
>           Specify the address in SDRAM for the SPL stack. This will be set up
>           before board_init_r() is called.
>
> +config SPL_STACK_R_MALLOC_SIMPLE_LEN
> +       depends on SPL_STACK_R && SPL_MALLOC_SIMPLE
> +       hex "Size of malloc_simple heap after switching to DRAM SPL stack"
> +       default 0x100000
> +       help
> +         Specify the amount of the stack to use as memory pool for
> +         malloc_simple after switching the stack to DRAM. This may be set
> +         to give board_init_r() a larger heap then the initial heap in
> +         SRAM which is limited to SYS_MALLOC_F_LEN bytes.
> +
>  config TPL
>         bool
>         depends on SPL && SUPPORT_TPL
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index b09a626..8c2d109 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -347,6 +347,15 @@ ulong spl_relocate_stack_gd(void)
>         memcpy(new_gd, (void *)gd, sizeof(gd_t));
>         gd = new_gd;
>
> +#ifdef CONFIG_SPL_MALLOC_SIMPLE
> +       if (CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN) {

Do you think we could do:

if (IS_ENABLED(CONFIG_SPL_MALLOC_SIMPLE) &&
CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN)

to avoid the #ifdef?

> +               ptr -= CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN;
> +               gd->malloc_base = ptr;
> +               gd->malloc_limit = CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN;
> +               gd->malloc_ptr = 0;
> +       }
> +#endif
> +
>         return ptr;
>  #else
>         return 0;
> --
> 2.4.3
>

I have to say I worry a little bit about combinatoric explosion with
this series. But I can't immediately see a better way.

Regards,
Simon

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

* [U-Boot] [PATCH 3/7] malloc_simple: Add Kconfig option for using only malloc_simple in the SPL
  2015-09-22  4:00   ` Simon Glass
@ 2015-09-22  9:38     ` Hans de Goede
  0 siblings, 0 replies; 21+ messages in thread
From: Hans de Goede @ 2015-09-22  9:38 UTC (permalink / raw)
  To: u-boot

Hi,

On 22-09-15 06:00, Simon Glass wrote:
> Hi Hans,
>
> On 13 September 2015 at 09:42, Hans de Goede <hdegoede@redhat.com> wrote:
>> common/dlmalloc.c is quite big, both in .text and .data usage, therefor
>> on some boards the SPL is build to use only malloc_simple.c and not the
>> dlmalloc.c code. This is done in various include/configs/foo.h with the
>> following construct:
>>
>
> Was there a '#' at the start of this missing line?

Yep, I keep falling over git commit eating up any lines starting with
a # when quoting code snippets in commit messages...

I will fix this and send a v2.

>> This commit introduces a SPL_MALLOC_SIMPLE Kconfig bool which allows
>> selecting this functionality through Kconfig instead.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>>   Kconfig                | 10 ++++++++++
>>   common/malloc_simple.c |  3 ++-
>>   include/_exports.h     |  3 ++-
>>   include/exports.h      |  3 ++-
>>   include/malloc.h       |  3 ++-
>>   5 files changed, 18 insertions(+), 4 deletions(-)
>>
>> diff --git a/Kconfig b/Kconfig
>> index 05a34f7..0ae4fab 100644
>> --- a/Kconfig
>> +++ b/Kconfig
>> @@ -114,6 +114,16 @@ config SPL
>>          help
>>            If you want to build SPL as well as the normal image, say Y.
>>
>> +config SPL_MALLOC_SIMPLE
>
> If you made it SPL_SYS_MALLOC_SIMPLE...
>
>> +       bool
>> +       depends on SPL
>> +       prompt "Only use malloc_simple functions in the spl"
>> +       help
>> +         Say Y here to only use the *_simple malloc functions from
>> +         malloc_simple.c, rather then using the versions from dlmalloc.c
>> +         this will make the SPL binary smaller at the cost of more heap
>> +         usage as the *_simple malloc functions do not re-use free-ed mem.
>> +
>>   config SPL_STACK_R
>>          depends on SPL
>>          bool "Enable SDRAM location for SPL stack"
>> diff --git a/common/malloc_simple.c b/common/malloc_simple.c
>> index c745863..e9c1eaa 100644
>> --- a/common/malloc_simple.c
>> +++ b/common/malloc_simple.c
>> @@ -40,7 +40,8 @@ void *memalign_simple(size_t align, size_t bytes)
>>          return ptr;
>>   }
>>
>> -#ifdef CONFIG_SYS_MALLOC_SIMPLE
>> +#if (defined CONFIG_SPL_BUILD && defined CONFIG_SPL_MALLOC_SIMPLE) || \
>> +    (defined CONFIG_SYS_MALLOC_SIMPLE)
>
> then I think this could become:
>
> #if CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)

I think you're right, good one. I'll give this a spin and
if it works include the change in V2.

>>   void *calloc(size_t nmemb, size_t elem_size)
>>   {
>>          size_t size = nmemb * elem_size;
>> diff --git a/include/_exports.h b/include/_exports.h
>> index 74a882a..f811c5d 100644
>> --- a/include/_exports.h
>> +++ b/include/_exports.h
>> @@ -23,7 +23,8 @@
>>          EXPORT_FUNC(dummy, void, free_hdlr, void)
>>   #endif
>>          EXPORT_FUNC(malloc, void *, malloc, size_t)
>> -#ifndef CONFIG_SYS_MALLOC_SIMPLE
>> +#if !(defined CONFIG_SPL_BUILD && defined CONFIG_SPL_MALLOC_SIMPLE) && \
>> +    !(defined CONFIG_SYS_MALLOC_SIMPLE)
>>          EXPORT_FUNC(free, void, free, void *)
>>   #endif
>>          EXPORT_FUNC(udelay, void, udelay, unsigned long)
>> diff --git a/include/exports.h b/include/exports.h
>> index a3e0469..8171b31 100644
>> --- a/include/exports.h
>> +++ b/include/exports.h
>> @@ -19,7 +19,8 @@ int printf(const char* fmt, ...);
>>   void install_hdlr(int, interrupt_handler_t, void*);
>>   void free_hdlr(int);
>>   void *malloc(size_t);
>> -#ifndef CONFIG_SYS_MALLOC_SIMPLE
>> +#if !(defined CONFIG_SPL_BUILD && defined CONFIG_SPL_MALLOC_SIMPLE) && \
>> +    !(defined CONFIG_SYS_MALLOC_SIMPLE)
>>   void free(void*);
>>   #endif
>>   void __udelay(unsigned long);
>> diff --git a/include/malloc.h b/include/malloc.h
>> index f4da9e6..e5592fc 100644
>> --- a/include/malloc.h
>> +++ b/include/malloc.h
>> @@ -872,7 +872,8 @@ extern Void_t*     sbrk();
>>
>>   #else
>>
>> -#ifdef CONFIG_SYS_MALLOC_SIMPLE
>> +#if (defined CONFIG_SPL_BUILD && defined CONFIG_SPL_MALLOC_SIMPLE) || \
>> +    (defined CONFIG_SYS_MALLOC_SIMPLE)
>>   #define malloc malloc_simple
>>   #define realloc realloc_simple
>>   #define memalign memalign_simple
>> --
>> 2.4.3
>>
>
> Regards,
> Simon
>

Regards,

Hans

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

* [U-Boot] [PATCH 4/7] malloc_simple: Add support for switching to DRAM heap
  2015-09-22  4:00   ` Simon Glass
@ 2015-09-22  9:52     ` Hans de Goede
  0 siblings, 0 replies; 21+ messages in thread
From: Hans de Goede @ 2015-09-22  9:52 UTC (permalink / raw)
  To: u-boot

Hi,

Thanks for all the reviews.

On 22-09-15 06:00, Simon Glass wrote:
> Hi Hans,
>
> On 13 September 2015 at 09:42, Hans de Goede <hdegoede@redhat.com> wrote:
>> malloc_simple uses a part of the stack as heap, initially it uses
>> SYS_MALLOC_F_LEN bytes which typically is quite small as the initial
>> stacks sits in SRAM and we do not have that much SRAM to work with.
>>
>> When DRAM becomes available we may switch the stack from SRAM to DRAM
>> to give use more room. This commit adds support for also switching to
>> a new bigger malloc_simple heap located in the new stack.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>>   Kconfig          | 10 ++++++++++
>>   common/spl/spl.c |  9 +++++++++
>>   2 files changed, 19 insertions(+)
>>
>> diff --git a/Kconfig b/Kconfig
>> index 0ae4fab..86088bc 100644
>> --- a/Kconfig
>> +++ b/Kconfig
>> @@ -142,6 +142,16 @@ config SPL_STACK_R_ADDR
>>            Specify the address in SDRAM for the SPL stack. This will be set up
>>            before board_init_r() is called.
>>
>> +config SPL_STACK_R_MALLOC_SIMPLE_LEN
>> +       depends on SPL_STACK_R && SPL_MALLOC_SIMPLE
>> +       hex "Size of malloc_simple heap after switching to DRAM SPL stack"
>> +       default 0x100000
>> +       help
>> +         Specify the amount of the stack to use as memory pool for
>> +         malloc_simple after switching the stack to DRAM. This may be set
>> +         to give board_init_r() a larger heap then the initial heap in
>> +         SRAM which is limited to SYS_MALLOC_F_LEN bytes.
>> +
>>   config TPL
>>          bool
>>          depends on SPL && SUPPORT_TPL
>> diff --git a/common/spl/spl.c b/common/spl/spl.c
>> index b09a626..8c2d109 100644
>> --- a/common/spl/spl.c
>> +++ b/common/spl/spl.c
>> @@ -347,6 +347,15 @@ ulong spl_relocate_stack_gd(void)
>>          memcpy(new_gd, (void *)gd, sizeof(gd_t));
>>          gd = new_gd;
>>
>> +#ifdef CONFIG_SPL_MALLOC_SIMPLE
>> +       if (CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN) {
>
> Do you think we could do:
>
> if (IS_ENABLED(CONFIG_SPL_MALLOC_SIMPLE) &&
> CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN)
>
> to avoid the #ifdef?

AFAIK we cannot do that because CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN will
not be defined if CONFIG_SPL_MALLOC_SIMPLE is not set, so then
the c compiler will end up looking for a symbol called
CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN and will not find it.

>> +               ptr -= CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN;
>> +               gd->malloc_base = ptr;
>> +               gd->malloc_limit = CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN;
>> +               gd->malloc_ptr = 0;
>> +       }
>> +#endif
>> +
>>          return ptr;
>>   #else
>>          return 0;
>> --
>> 2.4.3
>>
>
> I have to say I worry a little bit about combinatoric explosion with
> this series. But I can't immediately see a better way.

We could simply always relocate the heap when using malloc_simple and
CONFIG_SPL_STACK_R is set, code wise this would mean dropping the
CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN != 0 check, simplifying the code
somewhat (and allowing us to switch to using if (IS_ENABLED(CONFIG_SPL_MALLOC_SIMPLE)
instead #ifdef.

This will also half the number of memory layout variants we have in
the SPL, thus reducing the combinatoric explosion.

Downsides are:

1) If someone sets CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN to 0 things will
break. We can add text to the Kconfig help saying not to do that, which
IMHO is a good enough fix for this

2) This forces all users who use both SPL_STACK_R and SPL_SYS_MALLOC_SIMPLE
to also get their malloc_simple heap relocated, and I guess this may be
undesirable in some cases, although I cannot think of one.

2. is the reason why I wrote this patch as it is written, I have already
considered going the suggested route while writing the patch. I'm fine
either way though, if you think that making heap reloc mandatory when
using both SPL_STACK_R and SPL_SYS_MALLOC_SIMPLE that is fine with me.

Regards,

Hans

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

end of thread, other threads:[~2015-09-22  9:52 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-13 15:42 [U-Boot] [PATCH 0/7] malloc_simple: Add support for switching to DRAM heap Hans de Goede
2015-09-13 15:42 ` [U-Boot] [PATCH 1/7] spl: spl_relocate_stack_gd: Do not unnecessarily clear bss Hans de Goede
2015-09-22  4:00   ` Simon Glass
2015-09-13 15:42 ` [U-Boot] [PATCH 2/7] malloc_simple: Fix malloc_ptr calculation Hans de Goede
2015-09-22  4:00   ` Simon Glass
2015-09-13 15:42 ` [U-Boot] [PATCH 3/7] malloc_simple: Add Kconfig option for using only malloc_simple in the SPL Hans de Goede
2015-09-22  4:00   ` Simon Glass
2015-09-22  9:38     ` Hans de Goede
2015-09-13 15:42 ` [U-Boot] [PATCH 4/7] malloc_simple: Add support for switching to DRAM heap Hans de Goede
2015-09-22  4:00   ` Simon Glass
2015-09-22  9:52     ` Hans de Goede
2015-09-13 15:42 ` [U-Boot] [PATCH 5/7] sunxi: Simplify spl board_init_f function Hans de Goede
2015-09-13 16:27   ` Ian Campbell
2015-09-13 15:42 ` [U-Boot] [PATCH 6/7] sunxi: Enable CONFIG_SPL_STACK_R Hans de Goede
2015-09-13 16:33   ` Ian Campbell
2015-09-13 16:38     ` Hans de Goede
2015-09-13 18:50       ` Ian Campbell
2015-09-13 18:51         ` Hans de Goede
2015-09-14  6:00           ` Ian Campbell
2015-09-13 15:42 ` [U-Boot] [PATCH 7/7] sunxi: Switch to using malloc_simple for the spl Hans de Goede
2015-09-13 16:33   ` Ian Campbell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox