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

Commit f82ab04c authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "qseecom: fix a race condition when loading TA"

parents c767e408 5d02be98
Loading
Loading
Loading
Loading
+15 −4
Original line number Original line Diff line number Diff line
@@ -4061,8 +4061,11 @@ static int __qseecom_allocate_img_data(struct ion_handle **pihandle,
	int retry = 0;
	int retry = 0;


	do {
	do {
		if (retry++)
		if (retry++) {
			mutex_unlock(&app_access_lock);
			msleep(QSEECOM_TA_ION_ALLOCATE_DELAY);
			msleep(QSEECOM_TA_ION_ALLOCATE_DELAY);
			mutex_lock(&app_access_lock);
		}
		ihandle = ion_alloc(qseecom.ion_clnt, fw_size,
		ihandle = ion_alloc(qseecom.ion_clnt, fw_size,
			SZ_4K, ION_HEAP(ION_QSECOM_TA_HEAP_ID), 0);
			SZ_4K, ION_HEAP(ION_QSECOM_TA_HEAP_ID), 0);
	} while (IS_ERR_OR_NULL(ihandle) &&
	} while (IS_ERR_OR_NULL(ihandle) &&
@@ -4212,7 +4215,11 @@ static int __qseecom_load_fw(struct qseecom_dev_handle *data, char *appname,
	ret = qseecom_scm_call(SCM_SVC_TZSCHEDULER, 1, cmd_buf, cmd_len,
	ret = qseecom_scm_call(SCM_SVC_TZSCHEDULER, 1, cmd_buf, cmd_len,
			&resp, sizeof(resp));
			&resp, sizeof(resp));
	if (ret) {
	if (ret) {
		pr_err("scm_call to load failed : ret %d\n", ret);
		pr_err("scm_call to load failed : ret %d, result %x\n",
			ret, resp.result);
		if (resp.result == QSEOS_RESULT_FAIL_APP_ALREADY_LOADED)
			ret = -EEXIST;
		else
			ret = -EIO;
			ret = -EIO;
		goto exit_disable_clk_vote;
		goto exit_disable_clk_vote;
	}
	}
@@ -4465,6 +4472,7 @@ int qseecom_start_app(struct qseecom_handle **handle,
	}
	}
	mutex_lock(&app_access_lock);
	mutex_lock(&app_access_lock);


recheck:
	app_ireq.qsee_cmd_id = QSEOS_APP_LOOKUP_COMMAND;
	app_ireq.qsee_cmd_id = QSEOS_APP_LOOKUP_COMMAND;
	strlcpy(app_ireq.app_name, app_name, MAX_APP_NAME_SIZE);
	strlcpy(app_ireq.app_name, app_name, MAX_APP_NAME_SIZE);
	ret = __qseecom_check_app_exists(app_ireq, &app_id);
	ret = __qseecom_check_app_exists(app_ireq, &app_id);
@@ -4494,7 +4502,10 @@ int qseecom_start_app(struct qseecom_handle **handle,
		pr_debug("%s: Loading app for the first time'\n",
		pr_debug("%s: Loading app for the first time'\n",
				qseecom.pdev->init_name);
				qseecom.pdev->init_name);
		ret = __qseecom_load_fw(data, app_name, &app_id);
		ret = __qseecom_load_fw(data, app_name, &app_id);
		if (ret < 0)
		if (ret == -EEXIST) {
			pr_err("recheck if TA %s is loaded\n", app_name);
			goto recheck;
		} else if (ret < 0)
			goto exit_ion_free;
			goto exit_ion_free;
	}
	}
	data->client.app_id = app_id;
	data->client.app_id = app_id;
+2 −1
Original line number Original line Diff line number Diff line
/*
/*
 * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * it under the terms of the GNU General Public License version 2 and
@@ -19,6 +19,7 @@
#define QSEECOM_KEY_ID_SIZE   32
#define QSEECOM_KEY_ID_SIZE   32


#define QSEOS_RESULT_FAIL_SEND_CMD_NO_THREAD  -19   /*0xFFFFFFED*/
#define QSEOS_RESULT_FAIL_SEND_CMD_NO_THREAD  -19   /*0xFFFFFFED*/
#define QSEOS_RESULT_FAIL_APP_ALREADY_LOADED  -38   /*0xFFFFFFDA*/
#define QSEOS_RESULT_FAIL_UNSUPPORTED_CE_PIPE -63
#define QSEOS_RESULT_FAIL_UNSUPPORTED_CE_PIPE -63
#define QSEOS_RESULT_FAIL_KS_OP               -64
#define QSEOS_RESULT_FAIL_KS_OP               -64
#define QSEOS_RESULT_FAIL_KEY_ID_EXISTS       -65
#define QSEOS_RESULT_FAIL_KEY_ID_EXISTS       -65