Lines Matching refs:optee
58 static struct tee_shm *optee_shm_from_ffa_handle(struct optee *optee, in optee_shm_from_ffa_handle() argument
64 mutex_lock(&optee->ffa.mutex); in optee_shm_from_ffa_handle()
65 r = rhashtable_lookup_fast(&optee->ffa.global_ids, &global_id, in optee_shm_from_ffa_handle()
69 mutex_unlock(&optee->ffa.mutex); in optee_shm_from_ffa_handle()
74 static int optee_shm_add_ffa_handle(struct optee *optee, struct tee_shm *shm, in optee_shm_add_ffa_handle() argument
86 mutex_lock(&optee->ffa.mutex); in optee_shm_add_ffa_handle()
87 rc = rhashtable_lookup_insert_fast(&optee->ffa.global_ids, &r->linkage, in optee_shm_add_ffa_handle()
89 mutex_unlock(&optee->ffa.mutex); in optee_shm_add_ffa_handle()
97 static int optee_shm_rem_ffa_handle(struct optee *optee, u64 global_id) in optee_shm_rem_ffa_handle() argument
102 mutex_lock(&optee->ffa.mutex); in optee_shm_rem_ffa_handle()
103 r = rhashtable_lookup_fast(&optee->ffa.global_ids, &global_id, in optee_shm_rem_ffa_handle()
106 rc = rhashtable_remove_fast(&optee->ffa.global_ids, in optee_shm_rem_ffa_handle()
108 mutex_unlock(&optee->ffa.mutex); in optee_shm_rem_ffa_handle()
123 static void from_msg_param_ffa_mem(struct optee *optee, struct tee_param *p, in from_msg_param_ffa_mem() argument
135 shm = optee_shm_from_ffa_handle(optee, mp->u.fmem.global_id); in from_msg_param_ffa_mem()
155 static int optee_ffa_from_msg_param(struct optee *optee, in optee_ffa_from_msg_param() argument
179 from_msg_param_ffa_mem(optee, p, attr, mp); in optee_ffa_from_msg_param()
227 static int optee_ffa_to_msg_param(struct optee *optee, in optee_ffa_to_msg_param() argument
273 struct optee *optee = tee_get_drvdata(ctx->teedev); in optee_ffa_shm_register() local
274 struct ffa_device *ffa_dev = optee->ffa.ffa_dev; in optee_ffa_shm_register()
302 rc = optee_shm_add_ffa_handle(optee, shm, args.g_handle); in optee_ffa_shm_register()
316 struct optee *optee = tee_get_drvdata(ctx->teedev); in optee_ffa_shm_unregister() local
317 struct ffa_device *ffa_dev = optee->ffa.ffa_dev; in optee_ffa_shm_unregister()
328 optee_shm_rem_ffa_handle(optee, global_handle); in optee_ffa_shm_unregister()
345 struct optee *optee = tee_get_drvdata(ctx->teedev); in optee_ffa_shm_unregister_supp() local
356 optee_shm_rem_ffa_handle(optee, global_handle); in optee_ffa_shm_unregister_supp()
357 mem_ops = optee->ffa.ffa_dev->ops->mem_ops; in optee_ffa_shm_unregister_supp()
427 struct optee *optee, in handle_ffa_rpc_func_cmd_shm_alloc() argument
443 shm = tee_shm_alloc_priv_buf(optee->ctx, in handle_ffa_rpc_func_cmd_shm_alloc()
467 struct optee *optee, in handle_ffa_rpc_func_cmd_shm_free() argument
476 shm = optee_shm_from_ffa_handle(optee, arg->params[0].u.value.b); in handle_ffa_rpc_func_cmd_shm_free()
497 struct optee *optee, in handle_ffa_rpc_func_cmd() argument
503 handle_ffa_rpc_func_cmd_shm_alloc(ctx, optee, arg); in handle_ffa_rpc_func_cmd()
506 handle_ffa_rpc_func_cmd_shm_free(ctx, optee, arg); in handle_ffa_rpc_func_cmd()
509 optee_rpc_cmd(ctx, optee, arg); in handle_ffa_rpc_func_cmd()
513 static void optee_handle_ffa_rpc(struct tee_context *ctx, struct optee *optee, in optee_handle_ffa_rpc() argument
518 handle_ffa_rpc_func_cmd(ctx, optee, arg); in optee_handle_ffa_rpc()
533 struct optee *optee = tee_get_drvdata(ctx->teedev); in optee_ffa_yielding_call() local
534 struct ffa_device *ffa_dev = optee->ffa.ffa_dev; in optee_ffa_yielding_call()
544 optee_cq_wait_init(&optee->call_queue, &w); in optee_ffa_yielding_call()
563 optee_cq_wait_for_completion(&optee->call_queue, &w); in optee_ffa_yielding_call()
585 optee_handle_ffa_rpc(ctx, optee, data->data1, rpc_arg); in optee_ffa_yielding_call()
597 optee_cq_wait_final(&optee->call_queue, &w); in optee_ffa_yielding_call()
783 struct optee *optee = ffa_dev_get_drvdata(ffa_dev); in optee_ffa_remove() local
785 optee_remove_common(optee); in optee_ffa_remove()
787 mutex_destroy(&optee->ffa.mutex); in optee_ffa_remove()
788 rhashtable_free_and_destroy(&optee->ffa.global_ids, rh_free_fn, NULL); in optee_ffa_remove()
790 kfree(optee); in optee_ffa_remove()
801 struct optee *optee; in optee_ffa_probe() local
816 optee = kzalloc(sizeof(*optee), GFP_KERNEL); in optee_ffa_probe()
817 if (!optee) in optee_ffa_probe()
825 optee->pool = pool; in optee_ffa_probe()
827 optee->ops = &optee_ffa_ops; in optee_ffa_probe()
828 optee->ffa.ffa_dev = ffa_dev; in optee_ffa_probe()
829 optee->rpc_param_count = rpc_param_count; in optee_ffa_probe()
831 teedev = tee_device_alloc(&optee_ffa_clnt_desc, NULL, optee->pool, in optee_ffa_probe()
832 optee); in optee_ffa_probe()
837 optee->teedev = teedev; in optee_ffa_probe()
839 teedev = tee_device_alloc(&optee_ffa_supp_desc, NULL, optee->pool, in optee_ffa_probe()
840 optee); in optee_ffa_probe()
845 optee->supp_teedev = teedev; in optee_ffa_probe()
847 rc = tee_device_register(optee->teedev); in optee_ffa_probe()
851 rc = tee_device_register(optee->supp_teedev); in optee_ffa_probe()
855 rc = rhashtable_init(&optee->ffa.global_ids, &shm_rhash_params); in optee_ffa_probe()
858 mutex_init(&optee->ffa.mutex); in optee_ffa_probe()
859 mutex_init(&optee->call_queue.mutex); in optee_ffa_probe()
860 INIT_LIST_HEAD(&optee->call_queue.waiters); in optee_ffa_probe()
861 optee_supp_init(&optee->supp); in optee_ffa_probe()
862 optee_shm_arg_cache_init(optee, arg_cache_flags); in optee_ffa_probe()
863 ffa_dev_set_drvdata(ffa_dev, optee); in optee_ffa_probe()
864 ctx = teedev_open(optee->teedev); in optee_ffa_probe()
869 optee->ctx = ctx; in optee_ffa_probe()
870 rc = optee_notif_init(optee, OPTEE_DEFAULT_MAX_NOTIF_VALUE); in optee_ffa_probe()
883 optee_notif_uninit(optee); in optee_ffa_probe()
887 rhashtable_free_and_destroy(&optee->ffa.global_ids, rh_free_fn, NULL); in optee_ffa_probe()
888 optee_supp_uninit(&optee->supp); in optee_ffa_probe()
889 mutex_destroy(&optee->call_queue.mutex); in optee_ffa_probe()
890 mutex_destroy(&optee->ffa.mutex); in optee_ffa_probe()
892 tee_device_unregister(optee->supp_teedev); in optee_ffa_probe()
894 tee_device_unregister(optee->teedev); in optee_ffa_probe()
898 kfree(optee); in optee_ffa_probe()