From patchwork Wed Jan 19 14:54:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Weisser X-Patchwork-Id: 79480 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 15E4FB70AF for ; Thu, 20 Jan 2011 01:55:19 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 07685280D9; Wed, 19 Jan 2011 15:55:16 +0100 (CET) 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 v0LEXFP2H6+Z; Wed, 19 Jan 2011 15:55:15 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AE191280CE; Wed, 19 Jan 2011 15:55:14 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 25DD2280CE for ; Wed, 19 Jan 2011 15:55:12 +0100 (CET) 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 lwYe83U01xPl for ; Wed, 19 Jan 2011 15:55:10 +0100 (CET) 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-in-08.arcor-online.net (mail-in-08.arcor-online.net [151.189.21.48]) by theia.denx.de (Postfix) with ESMTPS id 0D53C280CD for ; Wed, 19 Jan 2011 15:55:08 +0100 (CET) Received: from mail-in-19-z2.arcor-online.net (mail-in-19-z2.arcor-online.net [151.189.8.36]) by mx.arcor.de (Postfix) with ESMTP id E0B4820574D for ; Wed, 19 Jan 2011 15:55:07 +0100 (CET) Received: from mail-in-12.arcor-online.net (mail-in-12.arcor-online.net [151.189.21.52]) by mail-in-19-z2.arcor-online.net (Postfix) with ESMTP id 57A27D7C4A; Wed, 19 Jan 2011 15:55:07 +0100 (CET) Received: from localhost.localdomain (unknown [212.87.136.142]) (Authenticated sender: weisserm@arcor.de) by mail-in-12.arcor-online.net (Postfix) with ESMTPA id E49532642F; Wed, 19 Jan 2011 15:55:06 +0100 (CET) X-DKIM: Sendmail DKIM Filter v2.8.2 mail-in-12.arcor-online.net E49532642F From: Matthias Weisser To: u-boot@lists.denx.de Date: Wed, 19 Jan 2011 15:54:56 +0100 Message-Id: <1295448896-3018-1-git-send-email-weisserm@arcor.de> X-Mailer: git-send-email 1.7.0.4 Subject: [U-Boot] [RFC PATCH] Speed up kernel decompression X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 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 This patch is not intended to go into mainline! It is just a RFC. Situation: Booting a LZO compressed legacy image containing an ELF (so, no linux) from flash takes about 1.6 seconds after issuing the bootm command to jumping to the elfs entry point when the patch regarding section copying I send earlier is applied. I felt that this could be optimized a bit. Approach: As the image is read twice from flash (CRC checking and decompressing) I tried to get it reduced to only reading the image once from flash. Please see the patch. Results: Copy from flash CRCing LZO Decompression | Total HEAD - 254ms 1600ms | 1854ms hacked 226ms 100ms 880ms | 1206ms 600ms are about 15% of the total boot time in our system. Problems: You need a quite big malloc pool. I found no easy way to free the allocated image memory after decompression. Signed-off-by: Matthias Weisser --- common/cmd_bootm.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 18019d6..0684bc0 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -722,6 +722,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) static image_header_t *image_get_kernel (ulong img_addr, int verify) { image_header_t *hdr = (image_header_t *)img_addr; + void *img_copy_ram; if (!image_check_magic(hdr)) { puts ("Bad Magic Number\n"); @@ -739,6 +740,12 @@ static image_header_t *image_get_kernel (ulong img_addr, int verify) show_boot_progress (3); image_print_contents (hdr); + img_copy_ram = malloc(image_get_image_size(hdr)); + if (img_copy_ram != NULL) { + memcpy(img_copy_ram, hdr, image_get_image_size(hdr)); + hdr = img_copy_ram; + } + if (verify) { puts (" Verifying Checksum ... "); if (!image_check_dcrc (hdr)) {