Lines Matching full: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()
148 * @optee: main service struct
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()
221 * @optee: main service struct
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()
534 struct optee *optee = tee_get_drvdata(ctx->teedev); in optee_ffa_yielding_call() local
535 struct ffa_device *ffa_dev = optee->ffa.ffa_dev; in optee_ffa_yielding_call()
545 optee_cq_wait_init(&optee->call_queue, &w, system_thread); in optee_ffa_yielding_call()
564 optee_cq_wait_for_completion(&optee->call_queue, &w); in optee_ffa_yielding_call()
586 optee_handle_ffa_rpc(ctx, optee, data->data1, rpc_arg); in optee_ffa_yielding_call()
598 optee_cq_wait_final(&optee->call_queue, &w); in optee_ffa_yielding_call()
726 struct optee *optee = cb_data; in notif_callback() local
728 if (notify_id == optee->ffa.bottom_half_value) in notif_callback()
729 optee_do_bottom_half(optee->ctx); in notif_callback()
731 optee_notif_send(optee, notify_id); in notif_callback()
734 static int enable_async_notif(struct optee *optee) in enable_async_notif() argument
736 struct ffa_device *ffa_dev = optee->ffa.ffa_dev; in enable_async_notif()
739 .data1 = optee->ffa.bottom_half_value, in enable_async_notif()
810 struct optee *optee = ffa_dev_get_drvdata(ffa_dev); in optee_ffa_remove() local
811 u32 bottom_half_id = optee->ffa.bottom_half_value; in optee_ffa_remove()
816 optee_remove_common(optee); in optee_ffa_remove()
818 mutex_destroy(&optee->ffa.mutex); in optee_ffa_remove()
819 rhashtable_free_and_destroy(&optee->ffa.global_ids, rh_free_fn, NULL); in optee_ffa_remove()
821 kfree(optee); in optee_ffa_remove()
825 struct optee *optee) in optee_ffa_async_notif_init() argument
835 optee, in optee_ffa_async_notif_init()
852 optee->ffa.bottom_half_value = notif_id; in optee_ffa_async_notif_init()
854 rc = enable_async_notif(optee); in optee_ffa_async_notif_init()
858 optee->ffa.bottom_half_value = U32_MAX; in optee_ffa_async_notif_init()
874 struct optee *optee; in optee_ffa_probe() local
890 optee = kzalloc(sizeof(*optee), GFP_KERNEL); in optee_ffa_probe()
891 if (!optee) in optee_ffa_probe()
899 optee->pool = pool; in optee_ffa_probe()
901 optee->ops = &optee_ffa_ops; in optee_ffa_probe()
902 optee->ffa.ffa_dev = ffa_dev; in optee_ffa_probe()
903 optee->ffa.bottom_half_value = U32_MAX; in optee_ffa_probe()
904 optee->rpc_param_count = rpc_param_count; in optee_ffa_probe()
906 teedev = tee_device_alloc(&optee_ffa_clnt_desc, NULL, optee->pool, in optee_ffa_probe()
907 optee); in optee_ffa_probe()
912 optee->teedev = teedev; in optee_ffa_probe()
914 teedev = tee_device_alloc(&optee_ffa_supp_desc, NULL, optee->pool, in optee_ffa_probe()
915 optee); in optee_ffa_probe()
920 optee->supp_teedev = teedev; in optee_ffa_probe()
922 rc = tee_device_register(optee->teedev); in optee_ffa_probe()
926 rc = tee_device_register(optee->supp_teedev); in optee_ffa_probe()
930 rc = rhashtable_init(&optee->ffa.global_ids, &shm_rhash_params); in optee_ffa_probe()
933 mutex_init(&optee->ffa.mutex); in optee_ffa_probe()
934 optee_cq_init(&optee->call_queue, 0); in optee_ffa_probe()
935 optee_supp_init(&optee->supp); in optee_ffa_probe()
936 optee_shm_arg_cache_init(optee, arg_cache_flags); in optee_ffa_probe()
937 ffa_dev_set_drvdata(ffa_dev, optee); in optee_ffa_probe()
938 ctx = teedev_open(optee->teedev); in optee_ffa_probe()
943 optee->ctx = ctx; in optee_ffa_probe()
944 rc = optee_notif_init(optee, OPTEE_DEFAULT_MAX_NOTIF_VALUE); in optee_ffa_probe()
948 rc = optee_ffa_async_notif_init(ffa_dev, optee); in optee_ffa_probe()
963 if (optee->ffa.bottom_half_value != U32_MAX) in optee_ffa_probe()
965 optee->ffa.bottom_half_value); in optee_ffa_probe()
966 optee_notif_uninit(optee); in optee_ffa_probe()
970 rhashtable_free_and_destroy(&optee->ffa.global_ids, rh_free_fn, NULL); in optee_ffa_probe()
971 optee_supp_uninit(&optee->supp); in optee_ffa_probe()
972 mutex_destroy(&optee->call_queue.mutex); in optee_ffa_probe()
973 mutex_destroy(&optee->ffa.mutex); in optee_ffa_probe()
975 tee_device_unregister(optee->supp_teedev); in optee_ffa_probe()
977 tee_device_unregister(optee->teedev); in optee_ffa_probe()
981 kfree(optee); in optee_ffa_probe()
993 .name = "optee",