From patchwork Fri Sep 20 13:35:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 276467 X-Patchwork-Delegate: trini@ti.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 6234D2C0156 for ; Fri, 20 Sep 2013 23:37:37 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 764244A1AD; Fri, 20 Sep 2013 15:37:34 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 UTROr1sppqzG; Fri, 20 Sep 2013 15:37:34 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BA99E4A19E; Fri, 20 Sep 2013 15:37:28 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4E8344A19F for ; Fri, 20 Sep 2013 15:37:21 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 VkJzARCmN-wr for ; Fri, 20 Sep 2013 15:37:15 +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-bk0-f51.google.com (mail-bk0-f51.google.com [209.85.214.51]) by theia.denx.de (Postfix) with ESMTPS id 6172B4A19E for ; Fri, 20 Sep 2013 15:37:09 +0200 (CEST) Received: by mail-bk0-f51.google.com with SMTP id mx10so187575bkb.38 for ; Fri, 20 Sep 2013 06:37:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=N8Ox1p4q3cFPaaaQqaNomfA4UFVEfZYOffU+ur793jE=; b=roOTcI+s7rC2oYv4QKe8N7Go8yM1e3zNHCGU4twOOJOO3zbaSFYvFb9VaA7a5DV3OI miCGDLbRDvyTsK0sLspGcKsPcPLeQ93IhLt1OxxwmLH+Ow26I8yvIXReYvweyBdnrf9f +kcFAFqpqLFa7dWMsufWzcy/0rnqFtSgV3aShJgGFyFbgxKPL08rmwb9CcORNIl1TA6e i0Ku1ldXjsLuSZwmKxHhxdMkmBoYMvR+Fqz8B0JznlHgz+ur5OJMRTDq9iuPG30Wy2ib TuclaA2LKuP0ToaC9tlXbd3Xvuru6x1pl8MYld4YXKaqXtGybYgRH1zN7aKdZATUR76L A+Mw== X-Received: by 10.204.103.199 with SMTP id l7mr5444801bko.11.1379684228990; Fri, 20 Sep 2013 06:37:08 -0700 (PDT) Received: from localhost (port-23010.pppoe.wtnet.de. [46.59.151.146]) by mx.google.com with ESMTPSA id qg7sm4641082bkb.6.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 20 Sep 2013 06:37:08 -0700 (PDT) From: Thierry Reding To: u-boot@lists.denx.de Date: Fri, 20 Sep 2013 15:35:52 +0200 Message-Id: <1379684152-24693-2-git-send-email-treding@nvidia.com> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1379684152-24693-1-git-send-email-treding@nvidia.com> References: <1379684152-24693-1-git-send-email-treding@nvidia.com> Subject: [U-Boot] [PATCH 2/2] image: Only relocate ramdisk when necessary X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de If a ramdisk has been loaded to low memory to begin with, there's no need to relocate it. Signed-off-by: Thierry Reding --- common/image.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/common/image.c b/common/image.c index 47336f2..d19c0e6 100644 --- a/common/image.c +++ b/common/image.c @@ -968,6 +968,8 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, * boot_ramdisk_high() takes a relocation hint from "initrd_high" environement * variable and if requested ramdisk data is moved to a specified location. If * no such hint is given, the default is to relocate the initrd to low memory. + * If the ramdisk is already in a proper location, skip relocation and use it + * in-place. * * Initrd_start and initrd_end are set to final (after relocation) ramdisk * start/end addresses if ramdisk image start and len were provided, @@ -1006,6 +1008,16 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len, initrd_high, initrd_copy_to_ram); if (rd_data) { + /* + * Only copy initrd if necessary. If it has been loaded to + * low memory, just skip relocation and use it in-place. + */ + ulong bootm_start = getenv_bootm_low(); + ulong rd_end = rd_data + rd_len; + + if (rd_data >= bootm_start && rd_end <= initrd_high) + initrd_copy_to_ram = 0; + if (!initrd_copy_to_ram) { /* zero-copy ramdisk support */ debug(" in-place initrd\n"); *initrd_start = rd_data;