From patchwork Sat May 21 01:05:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Rae X-Patchwork-Id: 624709 X-Patchwork-Delegate: p.marczak@samsung.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 3rBRl00pgCz9t6g for ; Sat, 21 May 2016 11:18:20 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9B47C4BD3D; Sat, 21 May 2016 03:18:11 +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 RT0gICoa1OBY; Sat, 21 May 2016 03:18:11 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 747EBA75CC; Sat, 21 May 2016 03:18:07 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A3FBDA7552 for ; Sat, 21 May 2016 03:18:03 +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 LnnOr2GFd5rX for ; Sat, 21 May 2016 03:18:03 +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-gw2-out.broadcom.com (mail-gw2-out.broadcom.com [216.31.210.63]) by theia.denx.de (Postfix) with ESMTP id 33FC6A75C6 for ; Sat, 21 May 2016 03:17:48 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.26,341,1459839600"; d="scan'208";a="95824112" Received: from mail-irv-18.broadcom.com ([10.15.198.37]) by mail-gw2-out.broadcom.com with ESMTP; 20 May 2016 18:23:59 -0700 Received: from mail-irva-12.broadcom.com (mail-irva-12.broadcom.com [10.11.16.101]) by mail-irv-18.broadcom.com (Postfix) with ESMTP id 9136C82025; Fri, 20 May 2016 18:07:38 -0700 (PDT) Received: from VM-host64-64-A1.ric.broadcom.com (lbrmn-vmlnx03.ric.broadcom.com [10.136.4.105]) by mail-irva-12.broadcom.com (Postfix) with ESMTP id 8C977127623; Fri, 20 May 2016 18:07:37 -0700 (PDT) From: Steve Rae To: u-boot@lists.denx.de Date: Fri, 20 May 2016 18:05:58 -0700 Message-Id: <1463792758-24338-6-git-send-email-srae@broadcom.com> X-Mailer: git-send-email 1.8.5 In-Reply-To: <1463792758-24338-1-git-send-email-srae@broadcom.com> References: <1463792758-24338-1-git-send-email-srae@broadcom.com> Cc: Steve Rae , Tom Rini , Stephen Warren Subject: [U-Boot] [PATCH 5/5] fastboot: sparse: improve CHUNK_TYPE_FILL write performance 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" - increase the size of the fill buffer - testing has shown a 10x improvement when the sparse image has large CHUNK_TYPE_FILL chunks Signed-off-by: Steve Rae --- common/image-sparse.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/common/image-sparse.c b/common/image-sparse.c index 9632c6f..ddf5772 100644 --- a/common/image-sparse.c +++ b/common/image-sparse.c @@ -1,4 +1,3 @@ - /* * Copyright (c) 2009, Google Inc. * All rights reserved. @@ -46,6 +45,10 @@ #include +#ifndef CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE +#define CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE (1024 * 512) +#endif + void write_sparse_image( struct sparse_storage *info, const char *part_name, void *data, unsigned sz) @@ -62,7 +65,11 @@ void write_sparse_image( sparse_header_t *sparse_header; chunk_header_t *chunk_header; uint32_t total_blocks = 0; + int fill_buf_num_blks; int i; + int j; + + fill_buf_num_blks = CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE / info->blksz; /* Read and skip over sparse image header */ sparse_header = (sparse_header_t *)data; @@ -169,8 +176,9 @@ void write_sparse_image( fill_buf = (uint32_t *) memalign(ARCH_DMA_MINALIGN, - ROUNDUP(info->blksz, - ARCH_DMA_MINALIGN)); + ROUNDUP( + info->blksz * fill_buf_num_blks, + ARCH_DMA_MINALIGN)); if (!fill_buf) { fastboot_fail( "Malloc failed for: CHUNK_TYPE_FILL"); @@ -180,7 +188,10 @@ void write_sparse_image( fill_val = *(uint32_t *)data; data = (char *)data + sizeof(uint32_t); - for (i = 0; i < (info->blksz / sizeof(fill_val)); i++) + for (i = 0; + i < (info->blksz * fill_buf_num_blks / + sizeof(fill_val)); + i++) fill_buf[i] = fill_val; if (blk + blkcnt > info->start + info->size) { @@ -192,18 +203,24 @@ void write_sparse_image( return; } - for (i = 0; i < blkcnt; i++) { - blks = info->write(info, blk, 1, fill_buf); - /* blks might be > 1 (eg. NAND bad-blocks) */ - if (blks < 1) { - printf("%s: %s, block # " LBAFU "\n", - __func__, "Write failed", blk); + for (i = 0; i < blkcnt;) { + j = blkcnt - i; + if (j > fill_buf_num_blks) + j = fill_buf_num_blks; + blks = info->write(info, blk, j, fill_buf); + /* blks might be > j (eg. NAND bad-blocks) */ + if (blks < j) { + printf("%s: %s " LBAFU " [%d]\n", + __func__, + "Write failed, block #", + blk, j); fastboot_fail( "flash write failure"); free(fill_buf); return; } blk += blks; + i += j; } bytes_written += blkcnt * info->blksz; total_blocks += chunk_data_sz / sparse_header->blk_sz;