summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorNamyoon Woo <namyoon@chromium.org>2020-02-04 16:50:29 -0800
committerCommit Bot <commit-bot@chromium.org>2020-02-19 20:47:16 +0000
commit3ac621b0628074bf7d93856fcd33b42b205c7a27 (patch)
tree362dc24bf5f27f01d4c8df620f541974f5b2b44d /board
parent9440fcfea914b8efc8ab5160326fcbeec78465e8 (diff)
downloadchrome-ec-3ac621b0628074bf7d93856fcd33b42b205c7a27.tar.gz
optimize read_tpm_nvmem()
This patch optimizes read_tpm_nvmem() by replacing NvGetIndexData() and NvGetIndexInfo() with NvReadIndexDta() and NvReadIndexInfo() respectively. This will reduce NvFindHandle() calls from three to one. BUG=b:148489182 BRANCH=cr50, cr50-mp TEST=The function execution time reduces from 1.2 msec to 550 usec. Cq-Depend:chromium:2038108 Change-Id: I6659480d8b60578f3d0b9dc3f62a677ae8489a57 Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2037920 Reviewed-by: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
Diffstat (limited to 'board')
-rw-r--r--board/cr50/tpm_nvmem_ops.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/board/cr50/tpm_nvmem_ops.c b/board/cr50/tpm_nvmem_ops.c
index 90bddfb313..9c29834756 100644
--- a/board/cr50/tpm_nvmem_ops.c
+++ b/board/cr50/tpm_nvmem_ops.c
@@ -21,16 +21,18 @@ enum tpm_read_rv read_tpm_nvmem(uint16_t obj_index,
{
TPM_HANDLE object_handle;
NV_INDEX nvIndex;
+ uint32_t handle_addr;
object_handle = HR_NV_INDEX + obj_index;
- if (!NvEarlyStageFindHandle(object_handle)) {
+ handle_addr = NvEarlyStageFindHandle(object_handle);
+ if (!handle_addr) {
CPRINTF("%s: object at 0x%x not found\n", __func__, obj_index);
return tpm_read_not_found;
}
/* Get properties of this index as stored in nvmem. */
- NvGetIndexInfo(object_handle, &nvIndex);
+ NvReadIndexInfo(object_handle, handle_addr, &nvIndex);
/*
* We presume it is readable and are not checking the access
@@ -49,7 +51,8 @@ enum tpm_read_rv read_tpm_nvmem(uint16_t obj_index,
}
/* Perform the read. */
- NvGetIndexData(object_handle, &nvIndex, 0, obj_size, obj_value);
+ NvReadIndexData(object_handle, &nvIndex, handle_addr, 0, obj_size,
+ obj_value);
return tpm_read_success;
}