From 3f13257ff666b9d8c8a79dbfa8104036cffc177b Mon Sep 17 00:00:00 2001 From: Zhen Kong Date: Thu, 2 Feb 2017 17:58:21 -0800 Subject: [PATCH] qseecom: add additonal reentrancy check before scm call scm call of send data will fail with EBUSY if there are more than one TAs requesting listener services, add additional checks before scm call and wait until no more than one listener request in the system. Change-Id: Ic891e687062dc52f02639605f3bac0e1c4540a6f Signed-off-by: Zhen Kong --- drivers/misc/qseecom.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/misc/qseecom.c b/drivers/misc/qseecom.c index 1653f7e1ae99..d3b41331faec 100644 --- a/drivers/misc/qseecom.c +++ b/drivers/misc/qseecom.c @@ -2135,22 +2135,24 @@ static void __qseecom_reentrancy_check_if_no_app_blocked(uint32_t smc_id) } /* - * scm_call send command to a blocked TZ app will fail - * So, first check and then wait until this apps is unblocked + * scm_call of send data will fail if this TA is blocked or there are more + * than one TA requesting listener services; So, first check to see if need + * to wait. */ static void __qseecom_reentrancy_check_if_this_app_blocked( struct qseecom_registered_app_list *ptr_app) { sigset_t new_sigset, old_sigset; if (qseecom.qsee_reentrancy_support) { - while (ptr_app->app_blocked) { + while (ptr_app->app_blocked || qseecom.app_block_ref_cnt > 1) { /* thread sleep until this app unblocked */ sigfillset(&new_sigset); sigprocmask(SIG_SETMASK, &new_sigset, &old_sigset); mutex_unlock(&app_access_lock); do { if (!wait_event_freezable(qseecom.app_block_wq, - !ptr_app->app_blocked)) + (!ptr_app->app_blocked && + qseecom.app_block_ref_cnt <= 1))) break; } while (1); mutex_lock(&app_access_lock);