[U-Boot,RFC] Speed up kernel decompression

Message ID 1295448896-3018-1-git-send-email-weisserm@arcor.de
State RFC
Headers show

Commit Message

Matthias Weisser Jan. 19, 2011, 2:54 p.m.
This patch is not intended to go into mainline! It is just a RFC.

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.

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

        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.

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 <weisserm@arcor.de>
 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)) {