summaryrefslogtreecommitdiff
authorMatthew Shyu <matthew.shyu@amlogic.com>2018-01-16 10:50:04 (GMT)
committer Matthew Shyu <matthew.shyu@amlogic.com>2018-01-16 10:50:04 (GMT)
commitee9f363f98df4f99de4efcec553f97ae654e474c (patch)
treea49cddf477c55ad6f2c2c3862b7328cb00455d87
parentcf15f941e9fa19e351b43856d62325c7ed0174f7 (diff)
downloadkeymaster-o-amlogic.zip
keymaster-o-amlogic.tar.gz
keymaster-o-amlogic.tar.bz2
keymaster: keymaster connection retry for FBE [3/4]
PD# 158397 Retry when connecting failed Change-Id: I48d81f2e5812baa7f162d15ac6697d80f23cf409
Diffstat
-rw-r--r--aml_keymaster_device.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/aml_keymaster_device.cpp b/aml_keymaster_device.cpp
index a1c80cb..7a8c785 100644
--- a/aml_keymaster_device.cpp
+++ b/aml_keymaster_device.cpp
@@ -41,6 +41,19 @@
#include "aml_keymaster_device.h"
#include "aml_keymaster_ipc.h"
+#ifndef KEYMASTER_TEMP_FAILURE_RETRY
+#define KEYMASTER_TEMP_FAILURE_RETRY(exp, retry) \
+ ({ \
+ __typeof__(exp) _rc; \
+ int count = 0; \
+ do { \
+ _rc = (exp); \
+ count ++; \
+ } while (_rc != TEEC_SUCCESS && count < retry); \
+ _rc; \
+ })
+#endif
+
const uint32_t RECV_BUF_SIZE = 66 * 1024;
const uint32_t SEND_BUF_SIZE = (66 * 1024 - sizeof(struct keymaster_message) - 16 /* tipc header */);
@@ -118,7 +131,8 @@ AmlKeymasterDevice::AmlKeymasterDevice(const hw_module_t* module) {
KM_session.ctx = NULL;
KM_session.session_id = 0;
- TEEC_Result rc = aml_keymaster_connect(&KM_context, &KM_session);
+
+ TEEC_Result rc = KEYMASTER_TEMP_FAILURE_RETRY(aml_keymaster_connect(&KM_context, &KM_session), 100);
error_ = translate_error(rc);
if (rc != TEEC_SUCCESS) {
ALOGE("failed to connect to keymaster (0x%x)", rc);