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 <zkong@codeaurora.org>
This commit is contained in:
Zhen Kong 2017-02-02 17:58:21 -08:00
parent 42e1251b38
commit 3f13257ff6

View file

@ -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);