Lines Matching full:optee
59 static struct tee_shm *optee_shm_from_ffa_handle(struct optee *optee, in optee_shm_from_ffa_handle() argument
65 mutex_lock(&optee->ffa.mutex); in optee_shm_from_ffa_handle()
66 r = rhashtable_lookup_fast(&optee->ffa.global_ids, &global_id, in optee_shm_from_ffa_handle()
70 mutex_unlock(&optee->ffa.mutex); in optee_shm_from_ffa_handle()
75 static int optee_shm_add_ffa_handle(struct optee *optee, struct tee_shm *shm, in optee_shm_add_ffa_handle() argument
87 mutex_lock(&optee->ffa.mutex); in optee_shm_add_ffa_handle()
88 rc = rhashtable_lookup_insert_fast(&optee->ffa.global_ids, &r->linkage, in optee_shm_add_ffa_handle()
90 mutex_unlock(&optee->ffa.mutex); in optee_shm_add_ffa_handle()
98 static int optee_shm_rem_ffa_handle(struct optee *optee, u64 global_id) in optee_shm_rem_ffa_handle() argument
103 mutex_lock(&optee->ffa.mutex); in optee_shm_rem_ffa_handle()
104 r = rhashtable_lookup_fast(&optee->ffa.global_ids, &global_id, in optee_shm_rem_ffa_handle()
107 rc = rhashtable_remove_fast(&optee->ffa.global_ids, in optee_shm_rem_ffa_handle()
109 mutex_unlock(&optee->ffa.mutex); in optee_shm_rem_ffa_handle()
124 static void from_msg_param_ffa_mem(struct optee *optee, struct tee_param *p, in from_msg_param_ffa_mem() argument
136 shm = optee_shm_from_ffa_handle(optee, mp->u.fmem.global_id); in from_msg_param_ffa_mem()
149 * @optee: main service struct
156 static int optee_ffa_from_msg_param(struct optee *optee, in optee_ffa_from_msg_param() argument
180 from_msg_param_ffa_mem(optee, p, attr, mp); in optee_ffa_from_msg_param()
222 * @optee: main service struct
228 static int optee_ffa_to_msg_param(struct optee *optee, in optee_ffa_to_msg_param() argument
274 struct optee *optee = tee_get_drvdata(ctx->teedev); in optee_ffa_shm_register() local
275 struct ffa_device *ffa_dev = optee->ffa.ffa_dev; in optee_ffa_shm_register()
303 rc = optee_shm_add_ffa_handle(optee, shm, args.g_handle); in optee_ffa_shm_register()
317 struct optee *optee = tee_get_drvdata(ctx->teedev); in optee_ffa_shm_unregister() local
318 struct ffa_device *ffa_dev = optee->ffa.ffa_dev; in optee_ffa_shm_unregister()
329 optee_shm_rem_ffa_handle(optee, global_handle); in optee_ffa_shm_unregister()
346 struct optee *optee = tee_get_drvdata(ctx->teedev); in optee_ffa_shm_unregister_supp() local
357 optee_shm_rem_ffa_handle(optee, global_handle); in optee_ffa_shm_unregister_supp()
358 mem_ops = optee->ffa.ffa_dev->ops->mem_ops; in optee_ffa_shm_unregister_supp()
428 struct optee *optee, in handle_ffa_rpc_func_cmd_shm_alloc() argument
444 shm = tee_shm_alloc_priv_buf(optee->ctx, in handle_ffa_rpc_func_cmd_shm_alloc()
468 struct optee *optee, in handle_ffa_rpc_func_cmd_shm_free() argument
477 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, in handle_ffa_rpc_func_cmd() argument
504 handle_ffa_rpc_func_cmd_shm_alloc(ctx, optee, arg); in handle_ffa_rpc_func_cmd()
507 handle_ffa_rpc_func_cmd_shm_free(ctx, optee, arg); in handle_ffa_rpc_func_cmd()
510 optee_rpc_cmd(ctx, optee, arg); in handle_ffa_rpc_func_cmd()
514 static void optee_handle_ffa_rpc(struct tee_context *ctx, struct optee *optee, in optee_handle_ffa_rpc() argument
519 handle_ffa_rpc_func_cmd(ctx, optee, arg); in optee_handle_ffa_rpc()
535 struct optee *optee = tee_get_drvdata(ctx->teedev); in optee_ffa_yielding_call() local
536 struct ffa_device *ffa_dev = optee->ffa.ffa_dev; in optee_ffa_yielding_call()
546 optee_cq_wait_init(&optee->call_queue, &w, system_thread); in optee_ffa_yielding_call()
565 optee_cq_wait_for_completion(&optee->call_queue, &w); in optee_ffa_yielding_call()
587 optee_handle_ffa_rpc(ctx, optee, data->data1, rpc_arg); in optee_ffa_yielding_call()
599 optee_cq_wait_final(&optee->call_queue, &w); in optee_ffa_yielding_call()
733 struct optee *optee = cb_data; in notif_callback() local
735 if (notify_id == optee->ffa.bottom_half_value) in notif_callback()
736 optee_do_bottom_half(optee->ctx); in notif_callback()
738 optee_notif_send(optee, notify_id); in notif_callback()
741 static int enable_async_notif(struct optee *optee) in enable_async_notif() argument
743 struct ffa_device *ffa_dev = optee->ffa.ffa_dev; in enable_async_notif()
746 .data1 = optee->ffa.bottom_half_value, in enable_async_notif()
817 struct optee *optee = ffa_dev_get_drvdata(ffa_dev); in optee_ffa_remove() local
818 u32 bottom_half_id = optee->ffa.bottom_half_value; in optee_ffa_remove()
823 optee_remove_common(optee); in optee_ffa_remove()
825 mutex_destroy(&optee->ffa.mutex); in optee_ffa_remove()
826 rhashtable_free_and_destroy(&optee->ffa.global_ids, rh_free_fn, NULL); in optee_ffa_remove()
828 kfree(optee); in optee_ffa_remove()
832 struct optee *optee) in optee_ffa_async_notif_init() argument
842 optee, in optee_ffa_async_notif_init()
859 optee->ffa.bottom_half_value = notif_id; in optee_ffa_async_notif_init()
861 rc = enable_async_notif(optee); in optee_ffa_async_notif_init()
865 optee->ffa.bottom_half_value = U32_MAX; in optee_ffa_async_notif_init()
881 struct optee *optee; in optee_ffa_probe() local
897 optee = kzalloc(sizeof(*optee), GFP_KERNEL); in optee_ffa_probe()
898 if (!optee) in optee_ffa_probe()
906 optee->pool = pool; in optee_ffa_probe()
908 optee->ops = &optee_ffa_ops; in optee_ffa_probe()
909 optee->ffa.ffa_dev = ffa_dev; in optee_ffa_probe()
910 optee->ffa.bottom_half_value = U32_MAX; in optee_ffa_probe()
911 optee->rpc_param_count = rpc_param_count; in optee_ffa_probe()
915 optee->in_kernel_rpmb_routing = true; in optee_ffa_probe()
917 teedev = tee_device_alloc(&optee_ffa_clnt_desc, NULL, optee->pool, in optee_ffa_probe()
918 optee); in optee_ffa_probe()
923 optee->teedev = teedev; in optee_ffa_probe()
925 teedev = tee_device_alloc(&optee_ffa_supp_desc, NULL, optee->pool, in optee_ffa_probe()
926 optee); in optee_ffa_probe()
931 optee->supp_teedev = teedev; in optee_ffa_probe()
933 optee_set_dev_group(optee); in optee_ffa_probe()
935 rc = tee_device_register(optee->teedev); in optee_ffa_probe()
939 rc = tee_device_register(optee->supp_teedev); in optee_ffa_probe()
943 rc = rhashtable_init(&optee->ffa.global_ids, &shm_rhash_params); in optee_ffa_probe()
946 mutex_init(&optee->ffa.mutex); in optee_ffa_probe()
947 optee_cq_init(&optee->call_queue, 0); in optee_ffa_probe()
948 optee_supp_init(&optee->supp); in optee_ffa_probe()
949 optee_shm_arg_cache_init(optee, arg_cache_flags); in optee_ffa_probe()
950 mutex_init(&optee->rpmb_dev_mutex); in optee_ffa_probe()
951 ffa_dev_set_drvdata(ffa_dev, optee); in optee_ffa_probe()
952 ctx = teedev_open(optee->teedev); in optee_ffa_probe()
957 optee->ctx = ctx; in optee_ffa_probe()
958 rc = optee_notif_init(optee, OPTEE_DEFAULT_MAX_NOTIF_VALUE); in optee_ffa_probe()
962 rc = optee_ffa_async_notif_init(ffa_dev, optee); in optee_ffa_probe()
972 INIT_WORK(&optee->rpmb_scan_bus_work, optee_bus_scan_rpmb); in optee_ffa_probe()
973 optee->rpmb_intf.notifier_call = optee_rpmb_intf_rdev; in optee_ffa_probe()
975 &optee->rpmb_intf); in optee_ffa_probe()
981 if (optee->ffa.bottom_half_value != U32_MAX) in optee_ffa_probe()
983 optee->ffa.bottom_half_value); in optee_ffa_probe()
984 optee_notif_uninit(optee); in optee_ffa_probe()
988 rhashtable_free_and_destroy(&optee->ffa.global_ids, rh_free_fn, NULL); in optee_ffa_probe()
989 rpmb_dev_put(optee->rpmb_dev); in optee_ffa_probe()
990 mutex_destroy(&optee->rpmb_dev_mutex); in optee_ffa_probe()
991 optee_supp_uninit(&optee->supp); in optee_ffa_probe()
992 mutex_destroy(&optee->call_queue.mutex); in optee_ffa_probe()
993 mutex_destroy(&optee->ffa.mutex); in optee_ffa_probe()
995 tee_device_unregister(optee->supp_teedev); in optee_ffa_probe()
997 tee_device_unregister(optee->teedev); in optee_ffa_probe()
1001 kfree(optee); in optee_ffa_probe()
1013 .name = "optee",