From patchwork Sun Sep 13 15:42:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 517193 X-Patchwork-Delegate: hdegoede@redhat.com 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 586FD140E42 for ; Mon, 14 Sep 2015 01:43:22 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 546894B7C9; Sun, 13 Sep 2015 17:43:18 +0200 (CEST) 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 EzT7fQ6-1XDW; Sun, 13 Sep 2015 17:43:18 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A07664B7F0; Sun, 13 Sep 2015 17:43:10 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8CF164B7AD for ; Sun, 13 Sep 2015 17:42:55 +0200 (CEST) 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 FynmNRNE1TQQ for ; Sun, 13 Sep 2015 17:42:55 +0200 (CEST) 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 mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by theia.denx.de (Postfix) with ESMTPS id 327074B786 for ; Sun, 13 Sep 2015 17:42:54 +0200 (CEST) Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 6728D8E3C8; Sun, 13 Sep 2015 15:42:53 +0000 (UTC) Received: from shalem.localdomain.com (vpn1-4-123.ams2.redhat.com [10.36.4.123]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8DFgkqq008364; Sun, 13 Sep 2015 11:42:52 -0400 From: Hans de Goede To: Ian Campbell , Simon Glass Date: Sun, 13 Sep 2015 17:42:42 +0200 Message-Id: <1442158965-29962-5-git-send-email-hdegoede@redhat.com> In-Reply-To: <1442158965-29962-1-git-send-email-hdegoede@redhat.com> References: <1442158965-29962-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 4/7] malloc_simple: Add support for switching to DRAM heap 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" malloc_simple uses a part of the stack as heap, initially it uses SYS_MALLOC_F_LEN bytes which typically is quite small as the initial stacks sits in SRAM and we do not have that much SRAM to work with. When DRAM becomes available we may switch the stack from SRAM to DRAM to give use more room. This commit adds support for also switching to a new bigger malloc_simple heap located in the new stack. Signed-off-by: Hans de Goede --- Kconfig | 10 ++++++++++ common/spl/spl.c | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/Kconfig b/Kconfig index 0ae4fab..86088bc 100644 --- a/Kconfig +++ b/Kconfig @@ -142,6 +142,16 @@ config SPL_STACK_R_ADDR Specify the address in SDRAM for the SPL stack. This will be set up before board_init_r() is called. +config SPL_STACK_R_MALLOC_SIMPLE_LEN + depends on SPL_STACK_R && SPL_MALLOC_SIMPLE + hex "Size of malloc_simple heap after switching to DRAM SPL stack" + default 0x100000 + help + Specify the amount of the stack to use as memory pool for + malloc_simple after switching the stack to DRAM. This may be set + to give board_init_r() a larger heap then the initial heap in + SRAM which is limited to SYS_MALLOC_F_LEN bytes. + config TPL bool depends on SPL && SUPPORT_TPL diff --git a/common/spl/spl.c b/common/spl/spl.c index b09a626..8c2d109 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -347,6 +347,15 @@ ulong spl_relocate_stack_gd(void) memcpy(new_gd, (void *)gd, sizeof(gd_t)); gd = new_gd; +#ifdef CONFIG_SPL_MALLOC_SIMPLE + if (CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN) { + ptr -= CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN; + gd->malloc_base = ptr; + gd->malloc_limit = CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN; + gd->malloc_ptr = 0; + } +#endif + return ptr; #else return 0;