From patchwork Thu Feb 23 01:59:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie Cai X-Patchwork-Id: 731367 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3vTHhc4VNYz9s7c for ; Thu, 23 Feb 2017 13:08:31 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JiegU5at"; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4BAEBA7C8C; Thu, 23 Feb 2017 03:08:14 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ysJMJ_pi3AWC; Thu, 23 Feb 2017 03:08:14 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4FDB0B3891; Thu, 23 Feb 2017 03:07:42 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D0EB34B6B3 for ; Thu, 23 Feb 2017 03:02:18 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nP948IjXz-Qq for ; Thu, 23 Feb 2017 03:01:51 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.66]) by theia.denx.de (Postfix) with ESMTPS id 9A671A7C95 for ; Thu, 23 Feb 2017 03:00:33 +0100 (CET) Received: by mail-pg0-f66.google.com with SMTP id 5so2680016pgj.0 for ; Wed, 22 Feb 2017 18:00:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RtX//bjZA32F75AqKBKkpwPLy3iaarvU4CEhIsoxt64=; b=JiegU5atZKRqr2tIu2jtYA47lRlJxVzpC8ZogusbjAUmn7zNFIwGPC3B3zmhHdBwms IK99By2G8XfK3DVFsAac7M5Jnj09Ekn9Lh2SOsriGhCtVfw3lut/3FwJ2a8KFiuhy88Z PjDg/VOrmmbSH/cczwY3nI78RKM7woh97AA0nsvjGZKNzHxwtPz1az6Z9v62t1Vti6I3 OKJavQxObQlbyRnBbRpkEJrWfDWbtARqtFFBIovHxClpqjFOl3YL/eeZVurU304WeEV4 jMZuP1BzPozvDDVOEGm4lcpQ8q7rhKzbqk9D2Z0LZI6FXdx3scR5yBm+uxqYAvNl39Fl pg8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RtX//bjZA32F75AqKBKkpwPLy3iaarvU4CEhIsoxt64=; b=TVAI5OsmDbcwGT3HCSnACyoxE78Y9SJUTgjoGs1t6upOW10b2ts0bkv73rfbtCDgKd A3QNDdt2dqbNfk+Z3XKr/Y1Z2esaqYR1qT9uSZbFex85qVEk2RKsDbTQOdTDd/wRa5Ym /5e9zm5HLTAuMMAFEpBxWrIccQhTHT52po/qGFtc9d79xtPaSiPsm4Rn7OwRYt144ADB CAQKmUcWujiMbgjkGl3Ba4159QGpZhBjNS906QZq1c2OGsOnCNM8GnM27dpvaXfMTTYW 1Y3IN9z+nns66jhEdfFhQ3YYZTsZ3EJ44uHh+8o+3jMFBJNVhyYLQ7bXSk8FLu1hW2Di 6LQA== X-Gm-Message-State: AMke39n4OJtP757MZo9+V/YAxu42bd7sXj3pn9lHCMqy/v+voCLVyF9iuxgKGDz3+KCwfA== X-Received: by 10.99.64.4 with SMTP id n4mr45172668pga.71.1487815231645; Wed, 22 Feb 2017 18:00:31 -0800 (PST) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id f78sm5818517pfe.116.2017.02.22.18.00.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Feb 2017 18:00:30 -0800 (PST) From: Eddie Cai To: sjg@chromium.org Date: Thu, 23 Feb 2017 09:59:45 +0800 Message-Id: <1487815186-24437-2-git-send-email-eddie.cai.linux@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487815186-24437-1-git-send-email-eddie.cai.linux@gmail.com> References: <1487815186-24437-1-git-send-email-eddie.cai.linux@gmail.com> Cc: u-boot@lists.denx.de Subject: [U-Boot] [U-Boot 1/2] spl: add spl_early_init X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Andrew F. Davis's below patch will make malloc_base, limit, ptr not initualized in spl_init when we call spl_init in board_init_f. Add spl_early_init which can be called in board_init_f to fix this issue. commit b3d2861eb20a795b99292b823c923935df26dfc6 Author: Andrew F. Davis Date: Fri Jan 27 10:39:19 2017 -0600 spl: Remove overwrite of relocated malloc limit Signed-off-by: Eddie Cai --- common/spl/spl.c | 54 +++++++++++++++++++++++++++++++++------ include/asm-generic/global_data.h | 1 + include/spl.h | 12 ++++++++- 3 files changed, 58 insertions(+), 9 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index 766fb3d..26bc9ef 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -170,21 +170,19 @@ __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) image_entry(); } -int spl_init(void) +int spl_early_init(void) { 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) #ifdef CONFIG_MALLOC_F_ADDR gd->malloc_base = CONFIG_MALLOC_F_ADDR; #endif +#ifdef CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN gd->malloc_limit = CONFIG_SYS_MALLOC_F_LEN; +#endif gd->malloc_ptr = 0; #endif if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) { @@ -202,6 +200,46 @@ int spl_init(void) return ret; } } + gd->flags |= GD_FLG_SPL_EARLY_INIT; + + return 0; +} + +int spl_init(void) +{ + 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 (!(gd->flags & GD_FLG_SPL_EARLY_INIT)) { +#if defined(CONFIG_SYS_MALLOC_F_LEN) && \ + !defined(CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN) +#ifdef CONFIG_MALLOC_F_ADDR + gd->malloc_base = CONFIG_MALLOC_F_ADDR; +#endif + 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(); + if (ret) { + debug("fdtdec_setup() returned error %d\n", ret); + return ret; + } + } + if (IS_ENABLED(CONFIG_SPL_DM)) { + /* With CONFIG_SPL_OF_PLATDATA, bring in all devices */ + ret = dm_init_and_scan(!CONFIG_IS_ENABLED(OF_PLATDATA)); + if (ret) { + debug("dm_init_and_scan() returned error %d\n", ret); + return ret; + } + } + } gd->flags |= GD_FLG_SPL_INIT; return 0; diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index e02863d..17ed3dc 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -127,5 +127,6 @@ typedef struct global_data { #define GD_FLG_SKIP_RELOC 0x00800 /* Don't relocate */ #define GD_FLG_RECORD 0x01000 /* Record console */ #define GD_FLG_ENV_DEFAULT 0x02000 /* Default variable flag */ +#define GD_FLG_SPL_EARLY_INIT 0x04000 /* Default variable flag */ #endif /* __ASM_GENERIC_GBL_DATA_H */ diff --git a/include/spl.h b/include/spl.h index bde4437..a89ac00 100644 --- a/include/spl.h +++ b/include/spl.h @@ -213,7 +213,7 @@ int spl_load_image_ext_os(struct spl_image_info *spl_image, struct blk_desc *block_dev, int partition); /** - * spl_init() - Set up device tree and driver model in SPL if enabled + * spl_early_init() - Set up device tree and driver model in SPL if enabled * * Call this function in board_init_f() if you want to use device tree and * driver model early, before board_init_r() is called. This function will @@ -222,6 +222,16 @@ int spl_load_image_ext_os(struct spl_image_info *spl_image, * If this is not called, then driver model will be inactive in SPL's * board_init_f(), and no device tree will be available. */ +int spl_early_init(void); + +/** + * spl_init() - Set up device tree and driver model in SPL if enabled + * + * This function will be called from board_init_r() if not called earlier. + * + * If this is not called, then driver model will be inactive in SPL's + * board_init_f(), and no device tree will be available. + */ int spl_init(void); #ifdef CONFIG_SPL_BOARD_INIT