summaryrefslogtreecommitdiff
path: root/common/vboot_hash.c
diff options
context:
space:
mode:
authorTing Shen <phoenixshen@google.com>2022-10-05 18:03:20 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-10-14 11:33:58 +0000
commit1e3f357cf83e49ae82795a7da6bf36cbac81eac0 (patch)
tree4bd71292fbc40515c21ad76b1842fd35f30cf592 /common/vboot_hash.c
parent77853a8e14842793bc5b8671343d06476b8410e5 (diff)
downloadchrome-ec-1e3f357cf83e49ae82795a7da6bf36cbac81eac0.tar.gz
vboot: remove unnecessary hash re-calculation
When EFS2 enabled, EC calculates the RW hash twice during boot. One in vboot_main() and another one in the init hook vboot_hash_init(). The second hash calculation is performed in a deferred task, and it's very slow on Krabby (~2 seconds), greatly affects boot time. Remove the second calculation since it seems unnecessary. BUG=b:239378639 TEST=1) manually tested sw sync on EFS2(krabby) and EFS1(coachz) device. 2) pass zephyr tests 3) boot speed improved on krabby BRANCH=none Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I32584524451ba261557e84e420a5869bf5fafc2f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3935121 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Diffstat (limited to 'common/vboot_hash.c')
-rw-r--r--common/vboot_hash.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/common/vboot_hash.c b/common/vboot_hash.c
index 75498edaaa..320574adc2 100644
--- a/common/vboot_hash.c
+++ b/common/vboot_hash.c
@@ -306,9 +306,18 @@ static void vboot_hash_init(void)
EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)))
#endif
{
- /* Start computing the hash of RW firmware */
- vboot_hash_start(flash_get_rw_offset(system_get_active_copy()),
- get_rw_size(), NULL, 0, VBOOT_HASH_DEFERRED);
+ /*
+ * At this point, it's likely that EFS2 vboot_main() already
+ * requested the RW hash calculation once.
+ *
+ * Start computing the hash of RW firmware only if we haven't
+ * done it before.
+ */
+ if (!hash) {
+ vboot_hash_start(
+ flash_get_rw_offset(system_get_active_copy()),
+ get_rw_size(), NULL, 0, VBOOT_HASH_DEFERRED);
+ }
}
}
DECLARE_HOOK(HOOK_INIT, vboot_hash_init, HOOK_PRIO_INIT_VBOOT_HASH);