All of lore.kernel.org
 help / color / mirror / Atom feed
From: Graeme Russ <graeme.russ@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v8] [RFC] early_malloc for DM added.
Date: Mon, 24 Sep 2012 10:46:39 +1000	[thread overview]
Message-ID: <CALButCKHVqPMMp-7Ly_aZmXT=fao8Y2HCfJ+VBMaNHW9Fr2jbQ@mail.gmail.com> (raw)
In-Reply-To: <CAEB7QLAu1Rxijzw+_+5Q520C4MUa=M-fBA=4Wy6x_5FTW01Fww@mail.gmail.com>

Hi Thomas,

On Mon, Sep 24, 2012 at 10:35 AM, Tomas Hlavacek <tmshlvck@gmail.com> wrote:
> Hi Graeme!
>
> On Mon, Sep 24, 2012 at 2:00 AM, Graeme Russ <graeme.russ@gmail.com> wrote:
>> Hi Tomas,
>>
>> On Mon, Sep 24, 2012 at 2:15 AM, Tomas Hlavacek <tmshlvck@gmail.com> wrote:
>>> early_malloc for DM with support for more heaps and lightweight
>>> first heap in the same memory as an early stack.
>>>
>>> Adaptation layer for seamless calling of early_malloc or dlmalloc from
>>> DM based on init stage added (dmmalloc() and related functions).
>>>
>>> Signed-off-by: Tomas Hlavacek <tmshlvck@gmail.com>
>>> ---
>>> Changelog since v5:
>>> dmmalloc() and all dm* functions has been moved to header, made static
>>> inline and preprocessor-dependent blocks are reworked.
>>> early_malloc_active() corrected and made not static.
>>> s/CONFIG_SYS_DM/CONFIG_DM/ applied.
>>>
>>> Changelog sice v6:
>>> Check of first heap emptyness in early_brk() has been simplified.
>>>
>>> Changelog since v7:
>>> dmcalloc() implmentation added.
>>> Comments added to header.
>>>
>>>  arch/arm/include/asm/global_data.h        |    3 +
>>>  arch/arm/lib/board.c                      |    8 ++
>>>  arch/avr32/include/asm/global_data.h      |    3 +
>>>  arch/avr32/lib/board.c                    |    9 +++
>>>  arch/blackfin/include/asm/global_data.h   |    3 +
>>>  arch/blackfin/lib/board.c                 |    8 ++
>>>  arch/m68k/include/asm/global_data.h       |    3 +
>>>  arch/m68k/lib/board.c                     |    8 ++
>>>  arch/microblaze/include/asm/global_data.h |    3 +
>>>  arch/microblaze/lib/board.c               |    9 +++
>>>  arch/mips/include/asm/global_data.h       |    3 +
>>>  arch/mips/lib/board.c                     |    8 ++
>>>  arch/nds32/include/asm/global_data.h      |    3 +
>>>  arch/nds32/lib/board.c                    |    8 ++
>>>  arch/nios2/include/asm/global_data.h      |    3 +
>>>  arch/nios2/lib/board.c                    |    8 ++
>>>  arch/openrisc/include/asm/global_data.h   |    3 +
>>>  arch/openrisc/lib/board.c                 |    8 ++
>>>  arch/powerpc/include/asm/global_data.h    |    3 +
>>>  arch/powerpc/lib/board.c                  |    8 ++
>>>  arch/sandbox/include/asm/global_data.h    |    3 +
>>>  arch/sandbox/lib/board.c                  |    8 ++
>>>  arch/sh/include/asm/global_data.h         |    3 +
>>>  arch/sh/lib/board.c                       |    8 ++
>>>  arch/sparc/include/asm/global_data.h      |    3 +
>>>  arch/sparc/lib/board.c                    |    8 ++
>>>  arch/x86/include/asm/global_data.h        |    3 +
>>>  arch/x86/lib/board.c                      |   18 +++++
>>>  common/Makefile                           |    1 +
>>>  common/dmmalloc.c                         |   88 ++++++++++++++++++++++
>>>  include/dmmalloc.h                        |  117 +++++++++++++++++++++++++++++
>>>  31 files changed, 372 insertions(+)
>>>  create mode 100644 common/dmmalloc.c
>>>  create mode 100644 include/dmmalloc.h
>>>
>>> diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h
>>> index f8088fe..ef727b0 100644
>>> --- a/arch/arm/include/asm/global_data.h
>>> +++ b/arch/arm/include/asm/global_data.h
>>> @@ -82,6 +82,9 @@ typedef       struct  global_data {
>>>         unsigned long   post_log_res; /* success of POST test */
>>>         unsigned long   post_init_f_time; /* When post_init_f started */
>>>  #endif
>>> +#ifdef CONFIG_SYS_EARLY_MALLOC
>>> +       void    *early_heap_first;      /* heap for early_malloc */
>>> +#endif
>>>  } gd_t;
>>>
>>>  #include <asm-generic/global_data_flags.h>
>>> diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
>>> index f1951e8..f73d8b2 100644
>>> --- a/arch/arm/lib/board.c
>>> +++ b/arch/arm/lib/board.c
>>> @@ -53,6 +53,10 @@
>>>  #include <post.h>
>>>  #include <logbuff.h>
>>>
>>> +#ifdef CONFIG_DM
>>> +#include <dmmalloc.h>
>>> +#endif
>>> +
>>>  #ifdef CONFIG_BITBANGMII
>>>  #include <miiphy.h>
>>>  #endif
>>> @@ -281,6 +285,10 @@ void board_init_f(ulong bootflag)
>>>
>>>         memset((void *)gd, 0, sizeof(gd_t));
>>>
>>> +#ifdef CONFIG_SYS_EARLY_MALLOC
>>> +       gd->early_heap_first = early_brk(CONFIG_SYS_EARLY_HEAP_SIZE);
>>> +#endif /* CONFIG_SYS_EARLY_MALLOC */
>>> +
>>
>> I just realised that all these initialisers can be dumped - early_brk()
>> will be called when early_malloc() is first called
>>
>
> Yes, but how can I determine the size of the new heap which the
> early_brk gives out? When I have CONFIG_SYS_EARLY_HEAP_SIZE macro in
> board configuration I can ignore the size passed to the "default"
> early_brk and return the full-sized heap as configuration says (when
> the requested size is lower than configured heap size and NULL

default early_brk() should always use CONFIG_SYS_EARLY_HEAP_SIZE

> otherwise). But what if somebody implements at some point a dynamic
> early_brk capable of returning multiple heaps? Should I safely assume
> that the future dynamic early_brk would give out multiples of page
> size or so?

Very good point. I would assume early_brk() will always return the
largest possible chunk of memory it can. These sizes might be
specified as multiple #defines in the board config or may be
dynamically determined via hardware probing. Either way, that is a
problem for the implementer to deal with :)

Regards,

Graeme

  reply	other threads:[~2012-09-24  0:46 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-27 12:12 [U-Boot] [PATCH 1/1] [RFC] DM: early_malloc for DM added Tomas Hlavacek
2012-08-27 12:18 ` Marek Vasut
2012-08-27 12:37   ` Tomas Hlavacek
2012-08-27 12:42 ` [U-Boot] [PATCHv2 " Tomas Hlavacek
2012-08-27 23:02   ` Graeme Russ
2012-08-28  0:11     ` Graeme Russ
2012-08-28  0:18     ` Graeme Russ
2012-09-18  7:13 ` [U-Boot] [PATCHv4] " Tomas Hlavacek
2012-09-18 10:57   ` Marek Vasut
2012-09-18 23:29     ` Graeme Russ
2012-09-18 23:33       ` Marek Vasut
2012-09-18 23:44         ` Graeme Russ
2012-09-18 23:53           ` Marek Vasut
2012-09-19 18:29       ` Tom Rini
2012-09-22  0:37       ` Tomas Hlavacek
2012-09-18 23:25   ` Graeme Russ
2012-09-22  0:25 ` [U-Boot] [PATCH v5] [RFC] " Tomas Hlavacek
2012-09-22  0:28   ` Marek Vasut
2012-09-22  7:52     ` Tomas Hlavacek
2012-09-22 13:19       ` Marek Vasut
2012-09-22 22:09 ` [U-Boot] [PATCH v6] " Tomas Hlavacek
2012-09-23 13:06   ` Graeme Russ
2012-09-23 15:30     ` Tomas Hlavacek
2012-09-23 15:38 ` [U-Boot] [PATCH v7] " Tomas Hlavacek
2012-09-23 16:15 ` [U-Boot] [PATCH v8] " Tomas Hlavacek
2012-09-23 16:32   ` Wolfgang Denk
2012-09-23 16:47     ` Tomas Hlavacek
2012-09-24 21:48       ` Tom Rini
2012-09-23 23:11   ` Marek Vasut
2012-09-24 14:16     ` Tomas Hlavacek
2012-09-24 14:19       ` Marek Vasut
2012-09-25  0:37         ` Graeme Russ
2012-09-25  8:43           ` Tomas Hlavacek
2012-09-25  9:09             ` Graeme Russ
2012-09-25 23:04               ` Graeme Russ
2012-09-26 10:16                 ` Tomas Hlavacek
2012-09-26 23:03                   ` Graeme Russ
2012-09-24  0:00   ` Graeme Russ
2012-09-24  0:35     ` Tomas Hlavacek
2012-09-24  0:46       ` Graeme Russ [this message]
2012-10-24 23:49 ` [U-Boot] [PATCH v9] [RFC] Add dmmalloc module for DM Tomas Hlavacek
2012-10-25  1:40   ` Graeme Russ
2012-10-25 19:16     ` Tomas Hlavacek
2012-10-25 23:04       ` Graeme Russ
2012-10-28 23:20 ` [U-Boot] [PATCH v10] " Tomas Hlavacek
2013-11-05 15:26   ` Mateusz Zalega
2013-11-05 17:17     ` Tom Rini
2013-11-05 17:26       ` Mateusz Zalega

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='CALButCKHVqPMMp-7Ly_aZmXT=fao8Y2HCfJ+VBMaNHW9Fr2jbQ@mail.gmail.com' \
    --to=graeme.russ@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.