-rw-r--r-- | aml_keymaster_device.cpp | 16 |
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); |