[PATCH] board_init: Convert CONFIG_MALLOC_F_ADDR to Kconfig

Tom Rini trini at konsulko.com
Wed Nov 30 15:49:18 CET 2022


On Sun, Nov 13, 2022 at 08:39:36PM +0100, Marek Vasut wrote:
> On 9/1/22 23:18, Tom Rini wrote:
> > On Sat, Jul 09, 2022 at 03:08:04AM +0200, Marek Vasut wrote:
> > 
> > > Convert CONFIG_MALLOC_F_ADDR to Kconfig.
> > > 
> > > The CL IoT gate board used MALLOC_F_ADDR 0x912000 on i.MX8M Mini unlike
> > > all the other platforms which use 0x930000 . This has been aligned with
> > > the other i.MX8M Mini platforms.
> > > 
> > > Signed-off-by: Marek Vasut <marex at denx.de>
> > [snip]
> > > diff --git a/common/init/board_init.c b/common/init/board_init.c
> > > index 6a550261778..35506f2ed35 100644
> > > --- a/common/init/board_init.c
> > > +++ b/common/init/board_init.c
> > > @@ -78,10 +78,8 @@ __weak void board_init_f_init_stack_protection(void)
> > >   ulong board_init_f_alloc_reserve(ulong top)
> > >   {
> > >   	/* Reserve early malloc arena */
> > > -#ifndef CONFIG_MALLOC_F_ADDR
> > > -#if CONFIG_VAL(SYS_MALLOC_F_LEN)
> > > +#if CONFIG_VAL(MALLOC_F_ADDR) && CONFIG_VAL(SYS_MALLOC_F_LEN)
> > >   	top -= CONFIG_VAL(SYS_MALLOC_F_LEN);
> > > -#endif
> > >   #endif
> > >   	/* LAST : reserve GD (rounded up to a multiple of 16 bytes) */
> > >   	top = rounddown(top-sizeof(struct global_data), 16);
> > 
> > This isn't equivalent. It was "if we don't have MALLOC_F_ADDR but do
> > have SYS_MALLOC_F_LEN ..." and now is "if we have MALLOC_F_ADDR and
> > SYS_MALLOC_F_LEN ...".
> 
> But this is not correct. It was
> 
> if
> CONFIG_MALLOC_F_ADDR is not declared
> and
> CONFIG_{SPL,TPL,...}SYS_MALLOC_F_LEN is non-zero
> 
> With the switch to Kconfig, the MALLOC_F_ADDR is always declared, except for
> the cases where it was not declared before, it is set to 0. So the change
> to:
> 
> if
> CONFIG_{SPL,TPL,...}MALLOC_F_ADDR is non-zero
> and
> CONFIG_{SPL,TPL,...}SYS_MALLOC_F_LEN is non-zero
> 
> seems equivalent to me, except of course for the handling of SPL/TPL part,
> which is done in the Kconfig

This is an annoying symbol to convert.  With the exception of sandbox
and kontron_sl28 (which I believe to be in error, no other imx boards do
this, and it is an anti-pattern to set this symbol the way it's been
set), this is only defined when CONFIG_SPL_BUILD is true. So we need to
rename it to CONFIG_SPL_MALLOC_F_ADDR and then use it. And then yes, we
need to switch to testing with CONFIG_VAL() and it being non-zero. I
know I didn't take your original patch, and dug in more here because
some platforms had binary size change here.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20221130/1d52c733/attachment.sig>


More information about the U-Boot mailing list