[PATCH v3 3/7] am65x: Use map_to_sysmem() to convert from pointer

Simon Glass sjg at chromium.org
Tue Oct 15 17:27:56 CEST 2024


Hi Tom,

On Tue, 15 Oct 2024 at 08:37, Tom Rini <trini at konsulko.com> wrote:
>
> On Tue, Oct 15, 2024 at 07:33:00AM -0600, Simon Glass wrote:
>
> > The board_init_f() function for am65x is a bit confusing, since it uses
> > the variable name 'pool_addr' to hold a pointer. It then casts it to an
> > address to pass to mem_alloc_init()
> >
> > Rename the variable and use mapmem to convert to an address.
> >
> > Signed-off-by: Simon Glass <sjg at chromium.org>
> > ---
> >
> > (no changes since v1)
> >
> >  arch/arm/mach-k3/am65x/am654_init.c | 11 ++++++-----
> >  1 file changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/arch/arm/mach-k3/am65x/am654_init.c b/arch/arm/mach-k3/am65x/am654_init.c
> > index a4f038029d7..ddcc1355210 100644
> > --- a/arch/arm/mach-k3/am65x/am654_init.c
> > +++ b/arch/arm/mach-k3/am65x/am654_init.c
> > @@ -8,6 +8,7 @@
> >
> >  #include <fdt_support.h>
> >  #include <init.h>
> > +#include <mapmem.h>
> >  #include <asm/global_data.h>
> >  #include <asm/io.h>
> >  #include <spl.h>
> > @@ -165,7 +166,7 @@ void board_init_f(ulong dummy)
> >  #if defined(CONFIG_K3_LOAD_SYSFW) || defined(CONFIG_K3_AM654_DDRSS)
> >       struct udevice *dev;
> >       size_t pool_size;
> > -     void *pool_addr;
> > +     void *pool;
> >       int ret;
> >  #endif
> >       /*
> > @@ -204,14 +205,14 @@ void board_init_f(ulong dummy)
> >        * malloc pool of which we use all that's left.
> >        */
> >       pool_size = CONFIG_VAL(SYS_MALLOC_F_LEN) - gd->malloc_ptr;
> > -     pool_addr = malloc(pool_size);
> > -     if (!pool_addr)
> > +     pool = malloc(pool_size);
> > +     if (!pool)
> >               panic("ERROR: Can't allocate full malloc pool!\n");
> >
> > -     mem_malloc_init((ulong)pool_addr, (ulong)pool_size);
> > +     mem_malloc_init(map_to_sysmem(pool), (ulong)pool_size);
> >       gd->flags |= GD_FLG_FULL_MALLOC_INIT;
> >       debug("%s: initialized an early full malloc pool at 0x%08lx of 0x%lx bytes\n",
> > -           __func__, (unsigned long)pool_addr, (unsigned long)pool_size);
> > +           __func__, (unsigned long)pool, (unsigned long)pool_size);
> >       /*
> >        * Process pinctrl for the serial0 a.k.a. WKUP_UART0 module and continue
> >        * regardless of the result of pinctrl. Do this without probing the
>
> This covers half of what we talked about in v2. But map_to_sysmem() is a
> sandbox thing that should not be called outside of (a) arch/sandbox or
> (b) common code that runs on sandbox. And honestly, we should work to
> hide that abstraction as much as we can, not start introducing it more.

Yes that's right. Perhaps we should document that.

We can drop this patch.

Regards,
Simon


More information about the U-Boot mailing list