Keep sun4v OF devices open. This can save 6 - 7 seconds per open call and can decrease boot times from over 10 minutes to a few seconds on larger SPARC systems. The open/close calls with some vendors' SAS controllers cause the entire card to be reinitialized after each close.
Signed-off-by: Eric Snowberg <[email protected]> --- grub-core/disk/ieee1275/ofdisk.c | 17 ++++++++++++++++- grub-core/kern/ieee1275/cmain.c | 4 ++++ include/grub/ieee1275/ieee1275.h | 2 ++ 3 files changed, 22 insertions(+), 1 deletions(-) diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c index 6789072..9c6b8b0 100644 --- a/grub-core/disk/ieee1275/ofdisk.c +++ b/grub-core/disk/ieee1275/ofdisk.c @@ -37,6 +37,7 @@ struct ofdisk_hash_ent int is_removable; int block_size_retries; grub_uint32_t block_size; + grub_ieee1275_ihandle_t ihandle; /* Pointer to shortest available name on nodes representing canonical names, otherwise NULL. */ const char *shortest; @@ -539,7 +540,7 @@ grub_ofdisk_close (grub_disk_t disk) { if (disk->data == last_devpath) { - if (last_ihandle) + if (! (grub_ieee1275_test_flag(GRUB_IEEE1275_FLAG_CACHE_OPEN)) && last_ihandle) grub_ieee1275_close (last_ihandle); last_ihandle = 0; last_devpath = NULL; @@ -733,6 +734,18 @@ grub_ofdisk_get_block_size (grub_uint32_t *block_size, struct ofdisk_hash_ent *o static grub_err_t grub_ofdisk_open_real (grub_disk_t disk) { + struct ofdisk_hash_ent *op = (struct ofdisk_hash_ent *)disk->id; + + if (!op) + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "BUG: can't open device "); + + if (grub_ieee1275_test_flag(GRUB_IEEE1275_FLAG_CACHE_OPEN) && op->ihandle) + { + last_ihandle = op->ihandle; + last_devpath = disk->data; + return 0; + } + if (last_ihandle) grub_ieee1275_close (last_ihandle); @@ -743,5 +756,7 @@ grub_ofdisk_open_real (grub_disk_t disk) if (! last_ihandle) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device"); + op->ihandle = last_ihandle; + last_devpath = disk->data; return 0; } diff --git a/grub-core/kern/ieee1275/cmain.c b/grub-core/kern/ieee1275/cmain.c index 3e12e6b..b016598 100644 --- a/grub-core/kern/ieee1275/cmain.c +++ b/grub-core/kern/ieee1275/cmain.c @@ -108,6 +108,10 @@ grub_ieee1275_find_options (void) if (rc >= 0) { char *ptr; + + if (grub_strncmp (tmp, "sun4v", 5) == 0) + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_CACHE_OPEN); + for (ptr = tmp; ptr - tmp < actual; ptr += grub_strlen (ptr) + 1) { if (grub_memcmp (ptr, "MacRISC", sizeof ("MacRISC") - 1) == 0 diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h index 8e42513..b79e97b 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h @@ -146,6 +146,8 @@ enum grub_ieee1275_flag GRUB_IEEE1275_FLAG_BROKEN_REPEAT, GRUB_IEEE1275_FLAG_CURSORONOFF_ANSI_BROKEN, + + GRUB_IEEE1275_FLAG_CACHE_OPEN, }; extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag); -- 1.7.1 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
