From patchwork Wed Dec 6 15:47:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick DELAUNAY X-Patchwork-Id: 845230 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3ysNLF73rPz9s03 for ; Thu, 7 Dec 2017 02:48:03 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id B6208C21EC8; Wed, 6 Dec 2017 15:47:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 945A4C21C59; Wed, 6 Dec 2017 15:47:56 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id EE475C21C59; Wed, 6 Dec 2017 15:47:54 +0000 (UTC) Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lists.denx.de (Postfix) with ESMTPS id A96D4C21C40 for ; Wed, 6 Dec 2017 15:47:53 +0000 (UTC) Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vB6FjD0O020151 for ; Wed, 6 Dec 2017 16:47:53 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2enqkvr52u-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 06 Dec 2017 16:47:53 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8A0C238 for ; Wed, 6 Dec 2017 15:47:52 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas23.st.com [10.75.90.46]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 4C01C5269; Wed, 6 Dec 2017 15:47:52 +0000 (GMT) Received: from SAFEX1HUBCAS24.st.com (10.75.90.95) by SAFEX1HUBCAS23.st.com (10.75.90.46) with Microsoft SMTP Server (TLS) id 14.3.352.0; Wed, 6 Dec 2017 16:47:52 +0100 Received: from localhost (10.201.23.85) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.352.0; Wed, 6 Dec 2017 16:47:51 +0100 From: Patrick Delaunay To: Date: Wed, 6 Dec 2017 16:47:43 +0100 Message-ID: <1512575263-23010-1-git-send-email-patrick.delaunay@st.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.201.23.85] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-12-06_07:, , signatures=0 Cc: CITOOLS , CIBUILD Subject: [U-Boot] [PATCH] common/memsize.c: restore content of the base address X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" In function get_ram_size() and for 2 last cases the content of the base address (*base) is not restored even it is correctly saved in stack (in save[i]). This patch solved this issue. The content of the base address is saved in new variable in stack (save_base) to avoid the need of other information (value of i) and restored in all the cases. Signed-off-by: Patrick Delaunay Reviewed-by: CITOOLS Reviewed-by: CIBUILD --- issue detected on my custom board with - base = 0xC0000000 - size = maxsize = 0x4000000 The loop is completely executed and the size is correctly detected, but content in 0xC0000000 is not restored So I have 0xC0000000 = 0x0 at the end of the function. That cause issue in my use-case because U-Boot in loaded at 0xC1000000 and some information can be saved by ATF in DDR at 0xC0000000 address. And the content of DDR is modified by this function. common/memsize.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/common/memsize.c b/common/memsize.c index 0fb9ba5..d632293 100644 --- a/common/memsize.c +++ b/common/memsize.c @@ -27,7 +27,8 @@ DECLARE_GLOBAL_DATA_PTR; long get_ram_size(long *base, long maxsize) { volatile long *addr; - long save[32]; + long save[31]; + long save_base; long cnt; long val; long size; @@ -43,7 +44,7 @@ long get_ram_size(long *base, long maxsize) addr = base; sync(); - save[i] = *addr; + save_base = *addr; sync(); *addr = 0; @@ -51,7 +52,7 @@ long get_ram_size(long *base, long maxsize) if ((val = *addr) != 0) { /* Restore the original data before leaving the function. */ sync(); - *addr = save[i]; + *base = save_base; for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) { addr = base + cnt; sync(); @@ -76,9 +77,11 @@ long get_ram_size(long *base, long maxsize) addr = base + cnt; *addr = save[--i]; } + *base = save_base; return (size); } } + *base = save_base; return (maxsize); }