From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Reding Date: Fri, 20 Sep 2013 15:35:52 +0200 Subject: [U-Boot] [PATCH 2/2] image: Only relocate ramdisk when necessary In-Reply-To: <1379684152-24693-1-git-send-email-treding@nvidia.com> References: <1379684152-24693-1-git-send-email-treding@nvidia.com> Message-ID: <1379684152-24693-2-git-send-email-treding@nvidia.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@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; -- 1.8.4