in amdtee/call.c [167:201]
int handle_unload_ta(u32 ta_handle)
{
struct tee_cmd_unload_ta cmd = {0};
u32 status, count;
int ret;
if (!ta_handle)
return -EINVAL;
mutex_lock(&ta_refcount_mutex);
count = put_ta_refcount(ta_handle);
if (count) {
pr_debug("unload ta: not unloading %u count %u\n",
ta_handle, count);
ret = -EBUSY;
goto unlock;
}
cmd.ta_handle = ta_handle;
ret = psp_tee_process_cmd(TEE_CMD_ID_UNLOAD_TA, (void *)&cmd,
sizeof(cmd), &status);
if (!ret && status != 0) {
pr_err("unload ta: status = 0x%x\n", status);
ret = -EBUSY;
} else {
pr_debug("unloaded ta handle %u\n", ta_handle);
}
unlock:
mutex_unlock(&ta_refcount_mutex);
return ret;
}