Message ID | 20190311213524.15893-6-simon.k.r.goldschmidt@gmail.com |
---|---|
State | Superseded |
Delegated to: | Tom Rini |
Headers | show |
Series | spl: full-featured heap cleanups | expand |
Hi Simon, On Tue, 12 Mar 2019 at 05:35, Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> wrote: > > Some platforms (like socfpga A10) need a big hep before SDRAM is available > (e.g. because FAT is used). For such platforms, simple_malloc is often not > a good option as it does not support freeing memory. These platforms often > use the non-Kconfig defines CONFIG_SYS_SPL_MALLOC_START (and its SIZE). > > This patch allows enabling CONFIG_SPL_SYS_MALLOC_F_LEN while leaving > CONFIG_SPL_SYS_MALLOC_SIMPLE disabled. In this case, the full malloc heap > is made available as early as the simple_malloc heap would be normally. > > This way, platforms can drop the non-Kconfig options to set up the full > heap and rely on the same automatically calculated heap allocation used > for simple heap. > > Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> > --- > > common/spl/spl.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/common/spl/spl.c b/common/spl/spl.c > index 88d4b8a9bf..b89340eb27 100644 > --- a/common/spl/spl.c > +++ b/common/spl/spl.c > @@ -383,8 +383,13 @@ static int spl_common_init(bool setup_malloc) > #ifdef CONFIG_MALLOC_F_ADDR > gd->malloc_base = CONFIG_MALLOC_F_ADDR; > #endif > +#if CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE) Can we use if() instead of #if here? > gd->malloc_limit = CONFIG_VAL(SYS_MALLOC_F_LEN); > gd->malloc_ptr = 0; > +#else > + mem_malloc_init(gd->malloc_base, CONFIG_VAL(SYS_MALLOC_F_LEN)); > + gd->flags |= GD_FLG_FULL_MALLOC_INIT; > +#endif > } > #endif > ret = bootstage_init(true); > -- > 2.17.1 > Also I feel some updates should be made to the README, or perhaps Kconfig help. Regards, Simon
Hi Simon, you were replying to v1 where v2 has already been sent. However, this patch hasn't changed, so I'm commenting here. Am 19.03.2019 um 02:24 schrieb Simon Glass: > Hi Simon, > > On Tue, 12 Mar 2019 at 05:35, Simon Goldschmidt > <simon.k.r.goldschmidt@gmail.com> wrote: >> >> Some platforms (like socfpga A10) need a big hep before SDRAM is available >> (e.g. because FAT is used). For such platforms, simple_malloc is often not >> a good option as it does not support freeing memory. These platforms often >> use the non-Kconfig defines CONFIG_SYS_SPL_MALLOC_START (and its SIZE). >> >> This patch allows enabling CONFIG_SPL_SYS_MALLOC_F_LEN while leaving >> CONFIG_SPL_SYS_MALLOC_SIMPLE disabled. In this case, the full malloc heap >> is made available as early as the simple_malloc heap would be normally. >> >> This way, platforms can drop the non-Kconfig options to set up the full >> heap and rely on the same automatically calculated heap allocation used >> for simple heap. >> >> Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> >> --- >> >> common/spl/spl.c | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/common/spl/spl.c b/common/spl/spl.c >> index 88d4b8a9bf..b89340eb27 100644 >> --- a/common/spl/spl.c >> +++ b/common/spl/spl.c >> @@ -383,8 +383,13 @@ static int spl_common_init(bool setup_malloc) >> #ifdef CONFIG_MALLOC_F_ADDR >> gd->malloc_base = CONFIG_MALLOC_F_ADDR; >> #endif >> +#if CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE) > > Can we use if() instead of #if here? Yes, that should work. Noted for v3. > >> gd->malloc_limit = CONFIG_VAL(SYS_MALLOC_F_LEN); >> gd->malloc_ptr = 0; >> +#else >> + mem_malloc_init(gd->malloc_base, CONFIG_VAL(SYS_MALLOC_F_LEN)); >> + gd->flags |= GD_FLG_FULL_MALLOC_INIT; >> +#endif >> } >> #endif >> ret = bootstage_init(true); >> -- >> 2.17.1 >> > > Also I feel some updates should be made to the README, or perhaps Kconfig help. Yes, you're right. Honestly, I didn't want to go through all the documentation mess unless getting at least some slightly positive feedback to this. Searching the readme files and Kconfig help to get them consistent is probably more work than coding these patches :-) Regards, Simon
diff --git a/common/spl/spl.c b/common/spl/spl.c index 88d4b8a9bf..b89340eb27 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -383,8 +383,13 @@ static int spl_common_init(bool setup_malloc) #ifdef CONFIG_MALLOC_F_ADDR gd->malloc_base = CONFIG_MALLOC_F_ADDR; #endif +#if CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE) gd->malloc_limit = CONFIG_VAL(SYS_MALLOC_F_LEN); gd->malloc_ptr = 0; +#else + mem_malloc_init(gd->malloc_base, CONFIG_VAL(SYS_MALLOC_F_LEN)); + gd->flags |= GD_FLG_FULL_MALLOC_INIT; +#endif } #endif ret = bootstage_init(true);
Some platforms (like socfpga A10) need a big hep before SDRAM is available (e.g. because FAT is used). For such platforms, simple_malloc is often not a good option as it does not support freeing memory. These platforms often use the non-Kconfig defines CONFIG_SYS_SPL_MALLOC_START (and its SIZE). This patch allows enabling CONFIG_SPL_SYS_MALLOC_F_LEN while leaving CONFIG_SPL_SYS_MALLOC_SIMPLE disabled. In this case, the full malloc heap is made available as early as the simple_malloc heap would be normally. This way, platforms can drop the non-Kconfig options to set up the full heap and rely on the same automatically calculated heap allocation used for simple heap. Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> --- common/spl/spl.c | 5 +++++ 1 file changed, 5 insertions(+)