summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2019-11-11 13:59:59 -0800
committerCommit Bot <commit-bot@chromium.org>2019-12-13 18:23:42 +0000
commitfa6119dc2cd69e711e9127241c2736e57706321c (patch)
treeaa422da105258d71b0e1bc7ada9751fa5ac0f369 /common
parent420abd92d8a437cde30115405a3fa883c7a7bccd (diff)
downloadchrome-ec-fa6119dc2cd69e711e9127241c2736e57706321c.tar.gz
nvmem: do not waste time looking for legacy NVMEM space
It takes 14.5 ms to decrypt two 12K flash spaces into SRAM, then calculate their hash to see if either one is is a valid NVMEM space. There is no need for this check when the 'other' Cr50 image is newer than {3,4}.18. BRANCH=Cr50, Cr50-mp BUG=b:132665283 TEST=with added instrumentation verified that in case the other slot is occupied by 0.0.22 image, the check takes 14.5 ms, when the other slot is occupied by 0.4.23 image the check takes 8 us. Change-Id: I0414ca3d7e90d343589a21e91319f35479632eff Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1967543 Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/nvmem.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/common/nvmem.c b/common/nvmem.c
index 4b4d8fc590..42fc0ba161 100644
--- a/common/nvmem.c
+++ b/common/nvmem.c
@@ -4,10 +4,10 @@
*/
#include "common.h"
+#include "board.h"
#include "console.h"
#include "dcrypto.h"
#include "flash.h"
-#include "nvmem.h"
#include "new_nvmem.h"
#include "task.h"
#include "timer.h"
@@ -313,7 +313,8 @@ int nvmem_init(void)
* Try discovering legacy partition(s). If even one is present, need
* to migrate to the new nvmem storage scheme.
*/
- if (nvmem_find_partition() == EC_SUCCESS)
+ if (board_nvmem_legacy_check_needed() &&
+ (nvmem_find_partition() == EC_SUCCESS))
ret = new_nvmem_migrate(nvmem_act_partition);
else
ret = new_nvmem_init();