Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zk5Cy-0002BT-OE for mharc-grub-devel@gnu.org; Thu, 08 Oct 2015 03:01:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39979) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjWE9-0000TD-6J for grub-devel@gnu.org; Tue, 06 Oct 2015 13:40:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZjWDy-0002ZH-9S for grub-devel@gnu.org; Tue, 06 Oct 2015 13:40:30 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:25787) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjWDy-0002Z3-2f for grub-devel@gnu.org; Tue, 06 Oct 2015 13:40:26 -0400 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t96HeOER030557 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 6 Oct 2015 17:40:25 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t96HeNGv008616 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Tue, 6 Oct 2015 17:40:24 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id t96HeNq4013279 for ; Tue, 6 Oct 2015 17:40:23 GMT Received: from ca-qasparc20.us.oracle.com (/10.147.24.73) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 06 Oct 2015 10:40:22 -0700 From: Eric Snowberg To: grub-devel@gnu.org Subject: [PATCH] sparc64: boot performance improvements Date: Tue, 6 Oct 2015 13:39:44 -0400 Message-Id: <1444153184-252565-1-git-send-email-eric.snowberg@oracle.com> X-Mailer: git-send-email 1.7.1 X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 Cc: Eric Snowberg X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Oct 2015 17:40:41 -0000 Keep of devices open. This can save 6 - 7 seconds per open call and can decrease boot times from over 10 minutes to 29 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 --- grub-core/kern/ieee1275/ieee1275.c | 39 ++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-) diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c index 9821702..30f973b 100644 --- a/grub-core/kern/ieee1275/ieee1275.c +++ b/grub-core/kern/ieee1275/ieee1275.c @@ -19,11 +19,24 @@ #include #include +#include +#include +#include #define IEEE1275_PHANDLE_INVALID ((grub_ieee1275_cell_t) -1) #define IEEE1275_IHANDLE_INVALID ((grub_ieee1275_cell_t) 0) #define IEEE1275_CELL_INVALID ((grub_ieee1275_cell_t) -1) +struct grub_of_opened_device +{ + struct grub_of_opened_device *next; + struct grub_of_opened_device **prev; + grub_ieee1275_ihandle_t ihandle; + char *path; +}; + +static struct grub_of_opened_device *grub_of_opened_devices; + int @@ -452,6 +465,18 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) } args; + struct grub_of_opened_device *dev; + + FOR_LIST_ELEMENTS(dev, grub_of_opened_devices) + if (grub_strcmp(dev->path, path) == 0) + break; + + if (dev) + { + *result = dev->ihandle; + return 0; + } + INIT_IEEE1275_COMMON (&args.common, "open", 1, 1); args.path = (grub_ieee1275_cell_t) path; @@ -460,6 +485,11 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) *result = args.result; if (args.result == IEEE1275_IHANDLE_INVALID) return -1; + + dev = grub_zalloc(sizeof(struct grub_of_opened_device)); + dev->path = grub_strdup(path); + dev->ihandle = args.result; + grub_list_push(GRUB_AS_LIST_P (&grub_of_opened_devices), GRUB_AS_LIST (dev)); return 0; } @@ -473,6 +503,15 @@ grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle) } args; + struct grub_of_opened_device *dev; + + FOR_LIST_ELEMENTS(dev, grub_of_opened_devices) + if (dev->ihandle == ihandle) + break; + + if (dev) + return 0; + INIT_IEEE1275_COMMON (&args.common, "close", 1, 0); args.ihandle = ihandle; -- 1.7.1