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

Commit 8cb0bc2c authored by Zhen Kong's avatar Zhen Kong Committed by Gerrit - the friendly Code Review server
Browse files

qseecom: make change for unload TA



When unloading a TA, the operations to check ref_cnt,
scm_call to unload TA, free app list entry should be
within one critical section. Otherwise, if another
thread comes in and tries to load TA, TA status will
be out-of-sync. so move __qseecom_cleanup_app()
and __qseecom_reentrancy_check_if_no_app_blocked()
to the beginning of qseecom_unload_app(), as these
functions may release app_access mutex for a short
period.

Change-Id: I3e961f4fe1728a32314a3acf7af719374c90d01f
Signed-off-by: default avatarZhen Kong <zkong@codeaurora.org>
parent 22c4c57b
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -432,7 +432,6 @@ static int qseecom_scm_call2(uint32_t svc_id, uint32_t tz_cmd_id,
			smc_id = TZ_OS_APP_SHUTDOWN_ID;
			desc.arginfo = TZ_OS_APP_SHUTDOWN_ID_PARAM_ID;
			desc.args[0] = req->app_id;
			__qseecom_reentrancy_check_if_no_app_blocked(smc_id);
			ret = scm_call2(smc_id, &desc);
			break;
		}
@@ -2218,6 +2217,9 @@ static int qseecom_unload_app(struct qseecom_dev_handle *data,
		return 0;
	}

	__qseecom_cleanup_app(data);
	__qseecom_reentrancy_check_if_no_app_blocked(TZ_OS_APP_SHUTDOWN_ID);

	if (data->client.app_id > 0) {
		spin_lock_irqsave(&qseecom.registered_app_list_lock, flags);
		list_for_each_entry(ptr_app, &qseecom.registered_app_list_head,
@@ -2246,11 +2248,9 @@ static int qseecom_unload_app(struct qseecom_dev_handle *data,
		}
	}

	if (found_dead_app) {
	if (found_dead_app)
		pr_warn("cleanup app_id %d(%s)\n", data->client.app_id,
			(char *)data->client.app_name);
		__qseecom_cleanup_app(data);
	}

	if (unload) {
		struct qseecom_unload_app_ireq req;
@@ -2279,7 +2279,6 @@ static int qseecom_unload_app(struct qseecom_dev_handle *data,
		if (resp.result == QSEOS_RESULT_SUCCESS)
			pr_debug("App (%d) is unloaded!!\n",
					data->client.app_id);
		__qseecom_cleanup_app(data);
		if (resp.result == QSEOS_RESULT_INCOMPLETE) {
			ret = __qseecom_process_incomplete_cmd(data, &resp);
			if (ret) {