mirror of
https://github.com/linux-sunxi/u-boot-sunxi.git
synced 2024-02-12 11:16:03 +08:00
fastboot: sparse: improve CHUNK_TYPE_FILL write performance
- 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 <srae@broadcom.com>
This commit is contained in:
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, Google Inc.
|
* Copyright (c) 2009, Google Inc.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -46,6 +45,10 @@
|
|||||||
|
|
||||||
#include <linux/math64.h>
|
#include <linux/math64.h>
|
||||||
|
|
||||||
|
#ifndef CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE
|
||||||
|
#define CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE (1024 * 512)
|
||||||
|
#endif
|
||||||
|
|
||||||
void write_sparse_image(
|
void write_sparse_image(
|
||||||
struct sparse_storage *info, const char *part_name,
|
struct sparse_storage *info, const char *part_name,
|
||||||
void *data, unsigned sz)
|
void *data, unsigned sz)
|
||||||
@ -62,7 +65,11 @@ void write_sparse_image(
|
|||||||
sparse_header_t *sparse_header;
|
sparse_header_t *sparse_header;
|
||||||
chunk_header_t *chunk_header;
|
chunk_header_t *chunk_header;
|
||||||
uint32_t total_blocks = 0;
|
uint32_t total_blocks = 0;
|
||||||
|
int fill_buf_num_blks;
|
||||||
int i;
|
int i;
|
||||||
|
int j;
|
||||||
|
|
||||||
|
fill_buf_num_blks = CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE / info->blksz;
|
||||||
|
|
||||||
/* Read and skip over sparse image header */
|
/* Read and skip over sparse image header */
|
||||||
sparse_header = (sparse_header_t *)data;
|
sparse_header = (sparse_header_t *)data;
|
||||||
@ -169,8 +176,9 @@ void write_sparse_image(
|
|||||||
|
|
||||||
fill_buf = (uint32_t *)
|
fill_buf = (uint32_t *)
|
||||||
memalign(ARCH_DMA_MINALIGN,
|
memalign(ARCH_DMA_MINALIGN,
|
||||||
ROUNDUP(info->blksz,
|
ROUNDUP(
|
||||||
ARCH_DMA_MINALIGN));
|
info->blksz * fill_buf_num_blks,
|
||||||
|
ARCH_DMA_MINALIGN));
|
||||||
if (!fill_buf) {
|
if (!fill_buf) {
|
||||||
fastboot_fail(
|
fastboot_fail(
|
||||||
"Malloc failed for: CHUNK_TYPE_FILL");
|
"Malloc failed for: CHUNK_TYPE_FILL");
|
||||||
@ -180,7 +188,10 @@ void write_sparse_image(
|
|||||||
fill_val = *(uint32_t *)data;
|
fill_val = *(uint32_t *)data;
|
||||||
data = (char *)data + sizeof(uint32_t);
|
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;
|
fill_buf[i] = fill_val;
|
||||||
|
|
||||||
if (blk + blkcnt > info->start + info->size) {
|
if (blk + blkcnt > info->start + info->size) {
|
||||||
@ -192,18 +203,24 @@ void write_sparse_image(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < blkcnt; i++) {
|
for (i = 0; i < blkcnt;) {
|
||||||
blks = info->write(info, blk, 1, fill_buf);
|
j = blkcnt - i;
|
||||||
/* blks might be > 1 (eg. NAND bad-blocks) */
|
if (j > fill_buf_num_blks)
|
||||||
if (blks < 1) {
|
j = fill_buf_num_blks;
|
||||||
printf("%s: %s, block # " LBAFU "\n",
|
blks = info->write(info, blk, j, fill_buf);
|
||||||
__func__, "Write failed", blk);
|
/* 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(
|
fastboot_fail(
|
||||||
"flash write failure");
|
"flash write failure");
|
||||||
free(fill_buf);
|
free(fill_buf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
blk += blks;
|
blk += blks;
|
||||||
|
i += j;
|
||||||
}
|
}
|
||||||
bytes_written += blkcnt * info->blksz;
|
bytes_written += blkcnt * info->blksz;
|
||||||
total_blocks += chunk_data_sz / sparse_header->blk_sz;
|
total_blocks += chunk_data_sz / sparse_header->blk_sz;
|
||||||
|
Reference in New Issue
Block a user