public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v6 1/4] Kconfig: Add SPL_SYS_MALLOC_CLEAR_ON_INIT
       [not found] <20230824162521.22240-1-wiagn233@outlook.com>
@ 2023-08-24 16:25 ` Shengyu Qu
  2023-08-24 16:31   ` Tom Rini
  2023-08-24 16:25 ` [PATCH v6 2/4] dlmalloc: Add support for SPL_SYS_MALLOC_CLEAR_ON_INIT Shengyu Qu
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Shengyu Qu @ 2023-08-24 16:25 UTC (permalink / raw)
  To: rick, ycliang, yanhong.wang, sjg, andre.przywara, xypron.glpk,
	michal.simek, marek.vasut+renesas, jbx6244, bmeng, ganboing,
	minda.chen, seanga2, u-boot
  Cc: Shengyu Qu

Add SPL version of SYS_MALLOC_CLEAR_ON_INIT, this would help devices
that need to clear ram before use to work correctly.

Signed-off-by: Bo Gan <ganboing@gmail.com>
Signed-off-by: Shengyu Qu <wiagn233@outlook.com>
---
 Changes since v5:
 - Fix whitespace
---
 Kconfig | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/Kconfig b/Kconfig
index 91170bf8d2..6ba605a564 100644
--- a/Kconfig
+++ b/Kconfig
@@ -372,6 +372,17 @@ if EXPERT
 	  When disabling this, please check if malloc calls, maybe
 	  should be replaced by calloc - if one expects zeroed memory.
 
+config SPL_SYS_MALLOC_CLEAR_ON_INIT
+	bool "Init with zeros the memory reserved for malloc (slow) in SPL"
+	depends on SPL
+	default SYS_MALLOC_CLEAR_ON_INIT
+	help
+	  Same as SYS_MALLOC_CLEAR_ON_INIT, but for SPL. It's possible to
+	  Enable it without SYS_MALLOC_CLEAR_ON_INIT. It's useful for boards
+	  that must have particular memory regions zero'ed before first use.
+	  If SYS_SPL_MALLOC_START is configured to be in such region, this
+	  option should be enabled.
+
 config SYS_MALLOC_DEFAULT_TO_INIT
 	bool "Default malloc to init while reserving the memory for it"
 	help
-- 
2.42.0


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

* [PATCH v6 2/4] dlmalloc: Add support for SPL_SYS_MALLOC_CLEAR_ON_INIT
       [not found] <20230824162521.22240-1-wiagn233@outlook.com>
  2023-08-24 16:25 ` [PATCH v6 1/4] Kconfig: Add SPL_SYS_MALLOC_CLEAR_ON_INIT Shengyu Qu
@ 2023-08-24 16:25 ` Shengyu Qu
  2023-08-24 16:25 ` [PATCH v6 3/4] riscv: cpu: jh7110: Imply SPL_SYS_MALLOC_CLEAR_ON_INIT Shengyu Qu
  2023-08-24 16:25 ` [PATCH v6 4/4] configs: starfive: Disable SYS_MALLOC_CLEAR_ON_INIT by default Shengyu Qu
  3 siblings, 0 replies; 7+ messages in thread
From: Shengyu Qu @ 2023-08-24 16:25 UTC (permalink / raw)
  To: rick, ycliang, yanhong.wang, sjg, andre.przywara, xypron.glpk,
	michal.simek, marek.vasut+renesas, jbx6244, bmeng, ganboing,
	minda.chen, seanga2, u-boot
  Cc: Shengyu Qu, Tom Rini

To support SPL_SYS_MALLOC_CLEAR_ON_INIT, we have to modify
#ifdef CONFIG_SYS_MALLOC_CLEAR_ON_INIT
to #if CONFIG_IS_ENABLED(SYS_MALLOC_CLEAR_ON_INIT)

Signed-off-by: Bo Gan <ganboing@gmail.com>
Signed-off-by: Shengyu Qu <wiagn233@outlook.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
 common/dlmalloc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index 0f9b7262d5..dcecdb8623 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -631,7 +631,7 @@ void mem_malloc_init(ulong start, ulong size)
 
 	debug("using memory %#lx-%#lx for malloc()\n", mem_malloc_start,
 	      mem_malloc_end);
-#ifdef CONFIG_SYS_MALLOC_CLEAR_ON_INIT
+#if CONFIG_IS_ENABLED(SYS_MALLOC_CLEAR_ON_INIT)
 	memset((void *)mem_malloc_start, 0x0, size);
 #endif
 	malloc_bin_reloc();
@@ -2153,7 +2153,7 @@ Void_t* cALLOc(n, elem_size) size_t n; size_t elem_size;
 
 
   /* check if expand_top called, in which case don't need to clear */
-#ifdef CONFIG_SYS_MALLOC_CLEAR_ON_INIT
+#if CONFIG_IS_ENABLED(SYS_MALLOC_CLEAR_ON_INIT)
 #if MORECORE_CLEARS
   mchunkptr oldtop = top;
   INTERNAL_SIZE_T oldtopsize = chunksize(top);
@@ -2184,7 +2184,7 @@ Void_t* cALLOc(n, elem_size) size_t n; size_t elem_size;
 
     csz = chunksize(p);
 
-#ifdef CONFIG_SYS_MALLOC_CLEAR_ON_INIT
+#if CONFIG_IS_ENABLED(SYS_MALLOC_CLEAR_ON_INIT)
 #if MORECORE_CLEARS
     if (p == oldtop && csz > oldtopsize)
     {
-- 
2.42.0


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

* [PATCH v6 3/4] riscv: cpu: jh7110: Imply SPL_SYS_MALLOC_CLEAR_ON_INIT
       [not found] <20230824162521.22240-1-wiagn233@outlook.com>
  2023-08-24 16:25 ` [PATCH v6 1/4] Kconfig: Add SPL_SYS_MALLOC_CLEAR_ON_INIT Shengyu Qu
  2023-08-24 16:25 ` [PATCH v6 2/4] dlmalloc: Add support for SPL_SYS_MALLOC_CLEAR_ON_INIT Shengyu Qu
@ 2023-08-24 16:25 ` Shengyu Qu
  2023-09-04  6:24   ` Leo Liang
  2023-08-24 16:25 ` [PATCH v6 4/4] configs: starfive: Disable SYS_MALLOC_CLEAR_ON_INIT by default Shengyu Qu
  3 siblings, 1 reply; 7+ messages in thread
From: Shengyu Qu @ 2023-08-24 16:25 UTC (permalink / raw)
  To: rick, ycliang, yanhong.wang, sjg, andre.przywara, xypron.glpk,
	michal.simek, marek.vasut+renesas, jbx6244, bmeng, ganboing,
	minda.chen, seanga2, u-boot
  Cc: Shengyu Qu

Starfive JH7110 needs to clear L2 LIM to zero before use or ECC error
would be triggered. Currently, we use DDR ram for SPL malloc arena on
Visionfive 2 board in defconfig, but it's also possible to use L2 LIM as
SPL malloc arena. To avoid triggering ECC error in this scenario, we
imply SPL_SYS_MALLOC_CLEAR_ON_INIT as default.

Signed-off-by: Bo Gan <ganboing@gmail.com>
Signed-off-by: Shengyu Qu <wiagn233@outlook.com>
---
 arch/riscv/cpu/jh7110/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/riscv/cpu/jh7110/Kconfig b/arch/riscv/cpu/jh7110/Kconfig
index 8469ee7de5..e5549a01b8 100644
--- a/arch/riscv/cpu/jh7110/Kconfig
+++ b/arch/riscv/cpu/jh7110/Kconfig
@@ -28,3 +28,4 @@ config STARFIVE_JH7110
 	imply SPL_LOAD_FIT
 	imply SPL_OPENSBI
 	imply SPL_RISCV_ACLINT
+	imply SPL_SYS_MALLOC_CLEAR_ON_INIT
-- 
2.42.0


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

* [PATCH v6 4/4] configs: starfive: Disable SYS_MALLOC_CLEAR_ON_INIT by default
       [not found] <20230824162521.22240-1-wiagn233@outlook.com>
                   ` (2 preceding siblings ...)
  2023-08-24 16:25 ` [PATCH v6 3/4] riscv: cpu: jh7110: Imply SPL_SYS_MALLOC_CLEAR_ON_INIT Shengyu Qu
@ 2023-08-24 16:25 ` Shengyu Qu
  2023-09-04  6:28   ` Leo Liang
  3 siblings, 1 reply; 7+ messages in thread
From: Shengyu Qu @ 2023-08-24 16:25 UTC (permalink / raw)
  To: rick, ycliang, yanhong.wang, sjg, andre.przywara, xypron.glpk,
	michal.simek, marek.vasut+renesas, jbx6244, bmeng, ganboing,
	minda.chen, seanga2, u-boot
  Cc: Shengyu Qu

SPL_SYS_MALLOC_CLEAR_ON_INIT would enable SYS_MALLOC_CLEAR_ON_INIT by
default, but that's not need on JH7110, so disable that.

Signed-off-by: Shengyu Qu <wiagn233@outlook.com>
---
 configs/starfive_visionfive2_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/starfive_visionfive2_defconfig b/configs/starfive_visionfive2_defconfig
index e9b63e5b84..efe3c2205a 100644
--- a/configs/starfive_visionfive2_defconfig
+++ b/configs/starfive_visionfive2_defconfig
@@ -58,6 +58,8 @@ CONFIG_SYS_SPL_MALLOC=y
 CONFIG_HAS_CUSTOM_SPL_MALLOC_START=y
 CONFIG_CUSTOM_SYS_SPL_MALLOC_ADDR=0x80000000
 CONFIG_SYS_SPL_MALLOC_SIZE=0x400000
+# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
+CONFIG_SPL_SYS_MALLOC_CLEAR_ON_INIT=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION=0x2
 CONFIG_SPL_I2C=y
-- 
2.42.0


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

* Re: [PATCH v6 1/4] Kconfig: Add SPL_SYS_MALLOC_CLEAR_ON_INIT
  2023-08-24 16:25 ` [PATCH v6 1/4] Kconfig: Add SPL_SYS_MALLOC_CLEAR_ON_INIT Shengyu Qu
@ 2023-08-24 16:31   ` Tom Rini
  0 siblings, 0 replies; 7+ messages in thread
From: Tom Rini @ 2023-08-24 16:31 UTC (permalink / raw)
  To: Shengyu Qu
  Cc: rick, ycliang, yanhong.wang, sjg, andre.przywara, xypron.glpk,
	michal.simek, marek.vasut+renesas, jbx6244, bmeng, ganboing,
	minda.chen, seanga2, u-boot

[-- Attachment #1: Type: text/plain, Size: 351 bytes --]

On Fri, Aug 25, 2023 at 12:25:18AM +0800, Shengyu Qu wrote:

> Add SPL version of SYS_MALLOC_CLEAR_ON_INIT, this would help devices
> that need to clear ram before use to work correctly.
> 
> Signed-off-by: Bo Gan <ganboing@gmail.com>
> Signed-off-by: Shengyu Qu <wiagn233@outlook.com>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

* Re: [PATCH v6 3/4] riscv: cpu: jh7110: Imply SPL_SYS_MALLOC_CLEAR_ON_INIT
  2023-08-24 16:25 ` [PATCH v6 3/4] riscv: cpu: jh7110: Imply SPL_SYS_MALLOC_CLEAR_ON_INIT Shengyu Qu
@ 2023-09-04  6:24   ` Leo Liang
  0 siblings, 0 replies; 7+ messages in thread
From: Leo Liang @ 2023-09-04  6:24 UTC (permalink / raw)
  To: Shengyu Qu
  Cc: rick, yanhong.wang, sjg, andre.przywara, xypron.glpk,
	michal.simek, marek.vasut+renesas, jbx6244, bmeng, ganboing,
	minda.chen, seanga2, u-boot

On Fri, Aug 25, 2023 at 12:25:20AM +0800, Shengyu Qu wrote:
> Starfive JH7110 needs to clear L2 LIM to zero before use or ECC error
> would be triggered. Currently, we use DDR ram for SPL malloc arena on
> Visionfive 2 board in defconfig, but it's also possible to use L2 LIM as
> SPL malloc arena. To avoid triggering ECC error in this scenario, we
> imply SPL_SYS_MALLOC_CLEAR_ON_INIT as default.
> 
> Signed-off-by: Bo Gan <ganboing@gmail.com>
> Signed-off-by: Shengyu Qu <wiagn233@outlook.com>
> ---
>  arch/riscv/cpu/jh7110/Kconfig | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>

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

* Re: [PATCH v6 4/4] configs: starfive: Disable SYS_MALLOC_CLEAR_ON_INIT by default
  2023-08-24 16:25 ` [PATCH v6 4/4] configs: starfive: Disable SYS_MALLOC_CLEAR_ON_INIT by default Shengyu Qu
@ 2023-09-04  6:28   ` Leo Liang
  0 siblings, 0 replies; 7+ messages in thread
From: Leo Liang @ 2023-09-04  6:28 UTC (permalink / raw)
  To: Shengyu Qu
  Cc: rick, yanhong.wang, sjg, andre.przywara, xypron.glpk,
	michal.simek, marek.vasut+renesas, jbx6244, bmeng, ganboing,
	minda.chen, seanga2, u-boot

On Fri, Aug 25, 2023 at 12:25:21AM +0800, Shengyu Qu wrote:
> SPL_SYS_MALLOC_CLEAR_ON_INIT would enable SYS_MALLOC_CLEAR_ON_INIT by
> default, but that's not need on JH7110, so disable that.
> 
> Signed-off-by: Shengyu Qu <wiagn233@outlook.com>
> ---
>  configs/starfive_visionfive2_defconfig | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>

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

end of thread, other threads:[~2023-09-04  6:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20230824162521.22240-1-wiagn233@outlook.com>
2023-08-24 16:25 ` [PATCH v6 1/4] Kconfig: Add SPL_SYS_MALLOC_CLEAR_ON_INIT Shengyu Qu
2023-08-24 16:31   ` Tom Rini
2023-08-24 16:25 ` [PATCH v6 2/4] dlmalloc: Add support for SPL_SYS_MALLOC_CLEAR_ON_INIT Shengyu Qu
2023-08-24 16:25 ` [PATCH v6 3/4] riscv: cpu: jh7110: Imply SPL_SYS_MALLOC_CLEAR_ON_INIT Shengyu Qu
2023-09-04  6:24   ` Leo Liang
2023-08-24 16:25 ` [PATCH v6 4/4] configs: starfive: Disable SYS_MALLOC_CLEAR_ON_INIT by default Shengyu Qu
2023-09-04  6:28   ` Leo Liang

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