From patchwork Fri May 8 21:51:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Harvey X-Patchwork-Id: 470192 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 3D92F140345 for ; Sat, 9 May 2015 07:51:53 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 104344B62A; Fri, 8 May 2015 23:51:51 +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 T9A-bgsOigHb; Fri, 8 May 2015 23:51:50 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 30D094B61E; Fri, 8 May 2015 23:51:50 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 92FD34B61E for ; Fri, 8 May 2015 23:51:47 +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 KgWFHIRbk6Hg for ; Fri, 8 May 2015 23:51:47 +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 mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by theia.denx.de (Postfix) with ESMTPS id 226CE4B617 for ; Fri, 8 May 2015 23:51:43 +0200 (CEST) Received: by pabsx10 with SMTP id sx10so59944388pab.3 for ; Fri, 08 May 2015 14:51:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+4qxzdTV5FVBZmXZGWwybjFi8wzUqT1Rnijn2LT6WwI=; b=HZHwC3JnbVeCk5duXP0ZD5OdnwKVfxQ1qXZnZ+viexc12oeKbFkOtWhT7cETQoFNtT sacuzX3KjnqqN30nnUig3ui1BAWYAHo7IAZyURKGIzwy0RatXv204w5LcH8hgM0Ram+A SEuWmCod6gRc/LDhRnfa9QCi9kVumCYdlkcJIMVPB7in+jXcJeQPTXBovhn0BRKvPOrl eOfDTj0bYG87fSZiSrvmNL38nWMT+MX7Ysz8ey6tA85qC4fdq92crBEpUMujr1DWx2gv dJufBkCZptCm8zBTogH4En95PHjjf8+f7SpMw8aDy12QKiFBAXOiomQCdb6c6hGZLsBQ sZsg== X-Gm-Message-State: ALoCoQlKM+qZGizMKMMCm7SfOAzozH5kadU7JiO0YmE90YP/i3OUujkE4Sbv84u1yE9GAiFf5RQO X-Received: by 10.68.92.5 with SMTP id ci5mr78181pbb.109.1431121902178; Fri, 08 May 2015 14:51:42 -0700 (PDT) Received: from tharvey.gw (68-189-91-139.static.snlo.ca.charter.com. [68.189.91.139]) by mx.google.com with ESMTPSA id a5sm6128945pdk.58.2015.05.08.14.51.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 May 2015 14:51:41 -0700 (PDT) From: Tim Harvey To: u-boot@lists.denx.de Date: Fri, 8 May 2015 14:51:36 -0700 Message-Id: <1431121896-2677-1-git-send-email-tharvey@gateworks.com> X-Mailer: git-send-email 1.9.1 Cc: Tom Rini , Hector Palacios , "Peter A. Bigot" , Marek Vasut Subject: [U-Boot] [PATCH] env_mmc: avoid stack allocation for env 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" Allocating space for temporary env on the stack makes env_relocate_spec() unsuitable for SPL environments which have very little stack. Signed-off-by: Tim Harvey --- common/env_mmc.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/common/env_mmc.c b/common/env_mmc.c index 6c4ce2f..19a28da 100644 --- a/common/env_mmc.c +++ b/common/env_mmc.c @@ -213,13 +213,19 @@ void env_relocate_spec(void) u32 offset1, offset2; int read1_fail = 0, read2_fail = 0; int crc1_ok = 0, crc2_ok = 0; - env_t *ep; + env_t *ep, *tmp_env1, *tmp_env2; int ret; int dev = CONFIG_SYS_MMC_ENV_DEV; const char *errmsg = NULL; - ALLOC_CACHE_ALIGN_BUFFER(env_t, tmp_env1, 1); - ALLOC_CACHE_ALIGN_BUFFER(env_t, tmp_env2, 1); + tmp_env1 = memalign(CONFIG_SYS_CACHELINE_SIZE, CONFIG_ENV_SIZE); + tmp_env2 = memalign(CONFIG_SYS_CACHELINE_SIZE, CONFIG_ENV_SIZE); + if (tmp_env1 == NULL || tmp_env2 == NULL) { + puts("Can't allocate buffers for environment\n"); + ret = 1; + errmsg = "!malloc() failed"; + goto err; + } #ifdef CONFIG_SPL_BUILD dev = 0; @@ -287,6 +293,8 @@ void env_relocate_spec(void) ret = 0; fini: + free(tmp_env1); + free(tmp_env2); fini_mmc_for_env(mmc); err: if (ret)