public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Tom Rini <trini@konsulko.com>
To: u-boot@lists.denx.de
Subject: [PATCH v3] malloc: dlmalloc: add an ability for the malloc to be re-init/init multiple times
Date: Fri, 1 May 2020 17:57:40 -0400	[thread overview]
Message-ID: <20200501215740.GZ12564@bill-the-cat> (raw)
In-Reply-To: <20200429162307.3685-1-marek.bykowski@gmail.com>

On Wed, Apr 29, 2020 at 06:23:07PM +0200, marek.bykowski at gmail.com wrote:

> From: Marek Bykowski <marek.bykowski@gmail.com>
> 
> Malloc gets initialized with a call to mem_malloc_init() with the address
> the allocation starts to and its size. Currently it is not possible to
> move the malloc from one memory area to another as the malloc would eventually
> fail.
> 
> This patch adds in the ability to re-init the malloc with the updated
> start address and the size.
> 
> One of the use cases of this feature is SPL U-Boot running from within
> the static memory and calling to malloc init from within board_init_f():
> 
> 	arch/arm/cpu/armv8/start.S:reset vector
> 	arch/arm/cpu/armv8/start.S:main()
> 	arch/arm/lib/crt0_64.S:board_init_f()
> 	board/<my_board>/common/spl.c:board_init_f()
>         board/<my_board>/common/spl.c:mem_malloc_init((ulong)CONFIG_SYS_SPL_MALLOC_START,
>                         CONFIG_SYS_SPL_MALLOC_SIZE);
> 
> Shortly after the DDR (main) memory is init and ready we call to malloc init
> again but this time with the start address in the DDR memory and a much greater
> size for moving the allocation off the static to the DDR memory:
> 
> 	board/<my_board>/common/spl.c:mem_malloc_init((ulong)CONFIG_SPL_MALLOC_OFFSET,
> 			CONFIG_SPL_MALLOC_SIZE);
> 
> Where CONFIG_SYS_SPL_MALLOC_START and CONFIG_SPL_MALLOC_OFFSET are the start
> addresses of the malloc in the static and DDR memories respectively and
> CONFIG_SYS_SPL_MALLOC_SIZE=SZ_16K and CONFIG_SPL_MALLOC_SIZE=SZ_2M are
> the sizes of the mallocs in these memories. Note, now we have a much greater
> memory, enlarging from 16K to 2M, available for allocation.
> 
> There is an alternative approach already existing in U-Boot with the use of
> an early (simplified) malloc and the proper (dlamalloc) malloc however
> necessitating managing the two mallocs whereas this approach proposes using
> a single dlmalloc.
> 
> Signed-off-by: Marek Bykowski <marek.bykowski@gmail.com>

Applied to u-boot/master, thanks!

-- 
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/20200501/7a7ae6ea/attachment-0001.sig>

      reply	other threads:[~2020-05-01 21:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-29 12:16 [PATCH] malloc: dlmalloc: add an ability for the malloc to be re-init/init multiple times marek.bykowski at gmail.com
2020-04-29 12:38 ` [PATCH v2] " marek.bykowski at gmail.com
2020-04-29 16:23   ` [PATCH v3] " marek.bykowski at gmail.com
2020-05-01 21:57     ` Tom Rini [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200501215740.GZ12564@bill-the-cat \
    --to=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox