From: Tom Rini <trini@konsulko.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 1/2] spl: Add spl_early_init()
Date: Mon, 20 Mar 2017 10:27:36 -0400 [thread overview]
Message-ID: <20170320142736.GU19897@bill-the-cat> (raw)
In-Reply-To: <7b9ecfb2-66f3-97e0-12d5-3443a07d87e6@ti.com>
On Mon, Mar 20, 2017 at 10:58:57AM +0530, Lokesh Vutla wrote:
> Hi Simon,
>
> On Wednesday 15 March 2017 08:13 PM, Simon Glass wrote:
> > From: Eddie Cai <eddie.cai.linux@gmail.com>
> >
> > At present malloc_base/_limit/_ptr are not initialised in spl_init() when
> > we call spl_init() in board_init_f(). This is due to a recent change aimed
> > at avoiding overwriting the malloc area set up on some boards by
> > spl_relocate_stack_gd().
> >
> > However if CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN is not defined, we now
> > skip setting up the memory area in spl_init() which is obviously wrong.
> >
> > To fix this, add a new function spl_early_init() which can be called in
> > board_init_f().
> >
> > Fixes: b3d2861e (spl: Remove overwrite of relocated malloc limit)
> > Signed-off-by: Eddie Cai <eddie.cai.linux@gmail.com>
> > Rewrote spl_{,early_}init() to avoid duplicate code:
> > Rewrite/expand commit message:
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> > Changes in v4: None
> > Changes in v3: None
> > Changes in v2:
> > - Rewrote spl_{,early_}init() to avoid duplicate code
> > - Rewrite commit message
> >
> > common/spl/spl.c | 46 +++++++++++++++++++++++++++++----------
> > include/asm-generic/global_data.h | 1 +
> > include/spl.h | 24 +++++++++++++++++---
> > 3 files changed, 57 insertions(+), 14 deletions(-)
> >
> > diff --git a/common/spl/spl.c b/common/spl/spl.c
> > index 766fb3d6f4..2bc8b42027 100644
> > --- a/common/spl/spl.c
> > +++ b/common/spl/spl.c
> > @@ -170,22 +170,20 @@ __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
> > image_entry();
> > }
> >
> > -int spl_init(void)
> > +static int spl_common_init(bool setup_malloc)
> > {
> > int ret;
> >
> > - debug("spl_init()\n");
> > -/*
> > - * with CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN we set malloc_base and
> > - * malloc_limit in spl_relocate_stack_gd
> > - */
> > -#if defined(CONFIG_SYS_MALLOC_F_LEN) && \
> > - !defined(CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN)
> > + debug("spl_early_init()\n");
> > +
> > +#if defined(CONFIG_SYS_MALLOC_F_LEN)
> > + if (setup_malloc) {
> > #ifdef CONFIG_MALLOC_F_ADDR
> > - gd->malloc_base = CONFIG_MALLOC_F_ADDR;
> > + gd->malloc_base = CONFIG_MALLOC_F_ADDR;
> > #endif
> > - gd->malloc_limit = CONFIG_SYS_MALLOC_F_LEN;
> > - gd->malloc_ptr = 0;
> > + gd->malloc_limit = CONFIG_SYS_MALLOC_F_LEN;
> > + gd->malloc_ptr = 0;
> > + }
> > #endif
> > if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) {
> > ret = fdtdec_setup();
> > @@ -202,6 +200,32 @@ int spl_init(void)
> > return ret;
> > }
> > }
> > +
> > + return 0;
> > +}
> > +
> > +int spl_early_init(void)
> > +{
> > + int ret;
> > +
> > + ret = spl_common_init(true);
> > + if (ret)
> > + return ret;
> > + gd->flags |= GD_FLG_SPL_EARLY_INIT;
> > +
> > + return 0;
> > +}
> > +
> > +int spl_init(void)
> > +{
> > + int ret;
> > +
> > + if (!(gd->flags & GD_FLG_SPL_EARLY_INIT)) {
> > + ret = spl_common_init(
> > + !IS_ENABLED(CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN));
>
> IS_ENABLED(CONFIG defined as hex) is always false. So this will always
> return true and overriding the malloc_limit, which is causing boot
> failures on DRA7xx based boards.:wq
Maybe we should use a bool that we set based on (SPL_STACK_R &&
SPL_SYS_MALLOC_SIMPLE) being true or not as that's the gating condition
for CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN being set.
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170320/39e51107/attachment.sig>
next prev parent reply other threads:[~2017-03-20 14:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-15 14:43 [U-Boot] [PATCH v4 1/2] spl: Add spl_early_init() Simon Glass
2017-03-15 14:43 ` [U-Boot] [PATCH v4 2/2] rockchip: rk3288: use spl_early_init() instead of spl_init() Simon Glass
2017-03-16 7:08 ` Kever Yang
2017-03-16 22:22 ` Simon Glass
2017-03-16 15:04 ` Eddie Cai
2017-03-16 22:22 ` Simon Glass
2017-03-16 15:02 ` [U-Boot] [PATCH v4 1/2] spl: Add spl_early_init() Eddie Cai
2017-03-16 22:22 ` Simon Glass
2017-03-17 12:09 ` Tom Rini
2017-03-20 5:28 ` Lokesh Vutla
2017-03-20 14:27 ` Tom Rini [this message]
2017-04-09 19:34 ` Simon Glass
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=20170320142736.GU19897@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 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.