in optee/smc_abi.c [288:322]
static void __optee_disable_shm_cache(struct optee *optee, bool is_mapped)
{
struct optee_call_waiter w;
/* We need to retry until secure world isn't busy. */
optee_cq_wait_init(&optee->call_queue, &w);
while (true) {
union {
struct arm_smccc_res smccc;
struct optee_smc_disable_shm_cache_result result;
} res;
optee->smc.invoke_fn(OPTEE_SMC_DISABLE_SHM_CACHE,
0, 0, 0, 0, 0, 0, 0, &res.smccc);
if (res.result.status == OPTEE_SMC_RETURN_ENOTAVAIL)
break; /* All shm's freed */
if (res.result.status == OPTEE_SMC_RETURN_OK) {
struct tee_shm *shm;
/*
* Shared memory references that were not mapped by
* this kernel must be ignored to prevent a crash.
*/
if (!is_mapped)
continue;
shm = reg_pair_to_ptr(res.result.shm_upper32,
res.result.shm_lower32);
tee_shm_free(shm);
} else {
optee_cq_wait_for_completion(&optee->call_queue, &w);
}
}
optee_cq_wait_final(&optee->call_queue, &w);
}