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 const struct ffa_dev_ops *ffa_ops = optee->ffa.ffa_ops; in optee_ffa_shm_register()
275 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 const struct ffa_dev_ops *ffa_ops = optee->ffa.ffa_ops; in optee_ffa_shm_unregister()
318 struct ffa_device *ffa_dev = optee->ffa.ffa_dev; in optee_ffa_shm_unregister()
327 optee_shm_rem_ffa_handle(optee, global_handle); in optee_ffa_shm_unregister()
344 struct optee *optee = tee_get_drvdata(ctx->teedev); in optee_ffa_shm_unregister_supp() local
345 const struct ffa_dev_ops *ffa_ops = optee->ffa.ffa_ops; in optee_ffa_shm_unregister_supp()
355 optee_shm_rem_ffa_handle(optee, global_handle); in optee_ffa_shm_unregister_supp()
466 struct optee *optee, in handle_ffa_rpc_func_cmd_shm_free() argument
475 shm = optee_shm_from_ffa_handle(optee, arg->params[0].u.value.b); in handle_ffa_rpc_func_cmd_shm_free()
498 struct optee *optee = tee_get_drvdata(ctx->teedev); in handle_ffa_rpc_func_cmd() local
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()
533 struct optee *optee = tee_get_drvdata(ctx->teedev); in optee_ffa_yielding_call() local
534 const struct ffa_dev_ops *ffa_ops = optee->ffa.ffa_ops; in optee_ffa_yielding_call()
535 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()
597 optee_cq_wait_final(&optee->call_queue, &w); in optee_ffa_yielding_call()
782 struct optee *optee = ffa_dev->dev.driver_data; in optee_ffa_remove() local
784 optee_remove_common(optee); in optee_ffa_remove()
786 mutex_destroy(&optee->ffa.mutex); in optee_ffa_remove()
787 rhashtable_free_and_destroy(&optee->ffa.global_ids, rh_free_fn, NULL); in optee_ffa_remove()
789 kfree(optee); in optee_ffa_remove()
797 struct optee *optee; in optee_ffa_probe() local
812 optee = kzalloc(sizeof(*optee), GFP_KERNEL); in optee_ffa_probe()
813 if (!optee) in optee_ffa_probe()
816 optee->pool = optee_ffa_config_dyn_shm(); in optee_ffa_probe()
817 if (IS_ERR(optee->pool)) { in optee_ffa_probe()
818 rc = PTR_ERR(optee->pool); in optee_ffa_probe()
819 optee->pool = NULL; in optee_ffa_probe()
823 optee->ops = &optee_ffa_ops; in optee_ffa_probe()
824 optee->ffa.ffa_dev = ffa_dev; in optee_ffa_probe()
825 optee->ffa.ffa_ops = ffa_ops; in optee_ffa_probe()
826 optee->rpc_arg_count = rpc_arg_count; in optee_ffa_probe()
828 teedev = tee_device_alloc(&optee_ffa_clnt_desc, NULL, optee->pool, in optee_ffa_probe()
829 optee); in optee_ffa_probe()
834 optee->teedev = teedev; in optee_ffa_probe()
836 teedev = tee_device_alloc(&optee_ffa_supp_desc, NULL, optee->pool, in optee_ffa_probe()
837 optee); in optee_ffa_probe()
842 optee->supp_teedev = teedev; in optee_ffa_probe()
844 rc = tee_device_register(optee->teedev); in optee_ffa_probe()
848 rc = tee_device_register(optee->supp_teedev); in optee_ffa_probe()
852 rc = rhashtable_init(&optee->ffa.global_ids, &shm_rhash_params); in optee_ffa_probe()
855 mutex_init(&optee->ffa.mutex); in optee_ffa_probe()
856 mutex_init(&optee->call_queue.mutex); in optee_ffa_probe()
857 INIT_LIST_HEAD(&optee->call_queue.waiters); in optee_ffa_probe()
858 optee_wait_queue_init(&optee->wait_queue); in optee_ffa_probe()
859 optee_supp_init(&optee->supp); in optee_ffa_probe()
860 ffa_dev_set_drvdata(ffa_dev, optee); in optee_ffa_probe()
876 tee_device_unregister(optee->supp_teedev); in optee_ffa_probe()
877 tee_device_unregister(optee->teedev); in optee_ffa_probe()
878 if (optee->pool) in optee_ffa_probe()
879 tee_shm_pool_free(optee->pool); in optee_ffa_probe()
880 kfree(optee); in optee_ffa_probe()