Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit de5f115d authored by sumikush's avatar sumikush
Browse files

qseecom: retry scm call if app is busy



When KeyMaster (KM) app is occupied by Identity Credential (IC) app and
any client requests some functionality from KM app then scm call failure 
is observed with response code indicating KM app is busy. In this case 
same scm call should be retried few more times to check if app can serve
it. Bail out with failure if retry count expires.

Change-Id: Icb092ff0a6b3b313197cf6a21f74caeaf6c576a1
Signed-off-by: default avatarsumikush <sumikush@codeaurora.org>
parent f04a23f2
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -470,6 +470,8 @@ static void __qseecom_free_coherent_buf(uint32_t size,
#define QSEECOM_SCM_EBUSY_WAIT_MS 30
#define QSEECOM_SCM_EBUSY_MAX_RETRY 67

#define QSEE_RESULT_FAIL_APP_BUSY 315

static int __qseecom_scm_call2_locked(uint32_t smc_id, struct scm_desc *desc)
{
	int ret = 0;
@@ -477,14 +479,14 @@ static int __qseecom_scm_call2_locked(uint32_t smc_id, struct scm_desc *desc)

	do {
		ret = qcom_scm_qseecom_call_noretry(smc_id, desc);
		if (ret == -EBUSY) {
		if ((ret == -EBUSY) || (desc && (desc->ret[0] == -QSEE_RESULT_FAIL_APP_BUSY))) {
			mutex_unlock(&app_access_lock);
			msleep(QSEECOM_SCM_EBUSY_WAIT_MS);
			mutex_lock(&app_access_lock);
		}
		if (retry_count == 33)
			pr_warn("secure world has been busy for 1 second!\n");
	} while (ret == -EBUSY &&
	} while (((ret == -EBUSY) || (desc && (desc->ret[0] == -QSEE_RESULT_FAIL_APP_BUSY))) &&
			(retry_count++ < QSEECOM_SCM_EBUSY_MAX_RETRY));
	return ret;
}