From b4d381380c62530874b7b1a353ac725e863f7760 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Mon, 1 Dec 2008 01:26:07 +0000 Subject: [PATCH] qi-fix-only-init-same-block-device-once.patch If we're accessing the same device, we don't need to keep init-ing it Signed-off-by: Andy Green --- qiboot/src/phase2.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/qiboot/src/phase2.c b/qiboot/src/phase2.c index 1d7e3c7..162c434 100644 --- a/qiboot/src/phase2.c +++ b/qiboot/src/phase2.c @@ -105,6 +105,8 @@ void bootloader_second_phase(void) unsigned int initramfs_len = 0; static char commandline_rootfs_append[512] = ""; int ret; + void * last_block_init = NULL; + int last_block_init_result = 0; /* we try the possible kernels for this board in order */ @@ -132,14 +134,26 @@ void bootloader_second_phase(void) indicate(UI_IND_MOUNT_PART); /* if this device needs initializing, try to init it */ - if (this_kernel->block_init) - if ((this_kernel->block_init)()) { + if (this_kernel->block_init) { + /* + * cache result to limit attempts for same + * block device to one time + */ + if (this_kernel->block_init != last_block_init) + last_block_init_result = + (this_kernel->block_init)(); + + if (last_block_init_result) { puts("block device init failed\n"); + if (this_kernel->block_init != last_block_init) + indicate(UI_IND_MOUNT_FAIL); this_kernel = &this_board-> kernel_source[kernel++]; - indicate(UI_IND_MOUNT_FAIL); + last_block_init = this_kernel->block_init; continue; } + last_block_init = this_kernel->block_init; + } /* if there's a partition table implied, parse it, otherwise * just use a fixed offset