Lines Matching refs:optee

117 static int optee_from_msg_param(struct optee *optee, struct tee_param *params,  in optee_from_msg_param()  argument
207 static int optee_to_msg_param(struct optee *optee, in optee_to_msg_param() argument
261 static void optee_enable_shm_cache(struct optee *optee) in optee_enable_shm_cache() argument
266 optee_cq_wait_init(&optee->call_queue, &w); in optee_enable_shm_cache()
270 optee->smc.invoke_fn(OPTEE_SMC_ENABLE_SHM_CACHE, in optee_enable_shm_cache()
274 optee_cq_wait_for_completion(&optee->call_queue, &w); in optee_enable_shm_cache()
276 optee_cq_wait_final(&optee->call_queue, &w); in optee_enable_shm_cache()
286 static void __optee_disable_shm_cache(struct optee *optee, bool is_mapped) in __optee_disable_shm_cache() argument
291 optee_cq_wait_init(&optee->call_queue, &w); in __optee_disable_shm_cache()
298 optee->smc.invoke_fn(OPTEE_SMC_DISABLE_SHM_CACHE, in __optee_disable_shm_cache()
316 optee_cq_wait_for_completion(&optee->call_queue, &w); in __optee_disable_shm_cache()
319 optee_cq_wait_final(&optee->call_queue, &w); in __optee_disable_shm_cache()
327 static void optee_disable_shm_cache(struct optee *optee) in optee_disable_shm_cache() argument
329 return __optee_disable_shm_cache(optee, true); in optee_disable_shm_cache()
338 static void optee_disable_unmapped_shm_cache(struct optee *optee) in optee_disable_unmapped_shm_cache() argument
340 return __optee_disable_shm_cache(optee, false); in optee_disable_unmapped_shm_cache()
436 struct optee *optee = tee_get_drvdata(ctx->teedev); in optee_shm_register() local
461 sz = optee_msg_arg_size(optee->rpc_param_count); in optee_shm_register()
490 if (optee->ops->do_call_with_arg(ctx, shm_arg, 0) || in optee_shm_register()
502 struct optee *optee = tee_get_drvdata(ctx->teedev); in optee_shm_unregister() local
517 sz = optee_msg_arg_size(optee->rpc_param_count); in optee_shm_unregister()
533 if (optee->ops->do_call_with_arg(ctx, shm_arg, 0) || in optee_shm_unregister()
657 struct optee *optee, in handle_rpc_func_cmd_shm_alloc() argument
687 shm = tee_shm_alloc_priv_buf(optee->ctx, sz); in handle_rpc_func_cmd_shm_alloc()
768 static void handle_rpc_func_cmd(struct tee_context *ctx, struct optee *optee, in handle_rpc_func_cmd() argument
776 handle_rpc_func_cmd_shm_alloc(ctx, optee, arg, call_ctx); in handle_rpc_func_cmd()
782 optee_rpc_cmd(ctx, optee, arg); in handle_rpc_func_cmd()
800 struct optee *optee = tee_get_drvdata(teedev); in optee_handle_rpc() local
807 shm = tee_shm_alloc_priv_buf(optee->ctx, param->a1); in optee_handle_rpc()
845 handle_rpc_func_cmd(ctx, optee, arg, call_ctx); in optee_handle_rpc()
870 struct optee *optee = tee_get_drvdata(ctx->teedev); in optee_smc_do_call_with_arg() local
877 if (optee->rpc_param_count) { in optee_smc_do_call_with_arg()
909 optee_cq_wait_init(&optee->call_queue, &w); in optee_smc_do_call_with_arg()
914 optee->smc.invoke_fn(param.a0, param.a1, param.a2, param.a3, in optee_smc_do_call_with_arg()
924 optee_cq_wait_for_completion(&optee->call_queue, &w); in optee_smc_do_call_with_arg()
943 optee_cq_wait_final(&optee->call_queue, &w); in optee_smc_do_call_with_arg()
996 struct optee *optee = dev_id; in notif_irq_handler() local
1003 value = get_async_notif_value(optee->smc.invoke_fn, in notif_irq_handler()
1011 optee_notif_send(optee, value); in notif_irq_handler()
1021 struct optee *optee = dev_id; in notif_irq_thread_fn() local
1023 optee_smc_do_bottom_half(optee->ctx); in notif_irq_thread_fn()
1028 static int optee_smc_notif_init_irq(struct optee *optee, u_int irq) in optee_smc_notif_init_irq() argument
1034 0, "optee_notification", optee); in optee_smc_notif_init_irq()
1038 optee->smc.notif_irq = irq; in optee_smc_notif_init_irq()
1043 static void optee_smc_notif_uninit_irq(struct optee *optee) in optee_smc_notif_uninit_irq() argument
1045 if (optee->smc.sec_caps & OPTEE_SMC_SEC_CAP_ASYNC_NOTIF) { in optee_smc_notif_uninit_irq()
1046 optee_smc_stop_async_notif(optee->ctx); in optee_smc_notif_uninit_irq()
1047 if (optee->smc.notif_irq) { in optee_smc_notif_uninit_irq()
1048 free_irq(optee->smc.notif_irq, optee); in optee_smc_notif_uninit_irq()
1049 irq_dispose_mapping(optee->smc.notif_irq); in optee_smc_notif_uninit_irq()
1071 struct optee *optee = tee_get_drvdata(teedev); in optee_get_version() local
1073 if (optee->smc.sec_caps & OPTEE_SMC_SEC_CAP_DYNAMIC_SHM) in optee_get_version()
1075 if (optee->smc.sec_caps & OPTEE_SMC_SEC_CAP_MEMREF_NULL) in optee_get_version()
1082 struct optee *optee = tee_get_drvdata(ctx->teedev); in optee_smc_open() local
1083 u32 sec_caps = optee->smc.sec_caps; in optee_smc_open()
1320 struct optee *optee = platform_get_drvdata(pdev); in optee_smc_remove() local
1327 if (!optee->rpc_param_count) in optee_smc_remove()
1328 optee_disable_shm_cache(optee); in optee_smc_remove()
1330 optee_smc_notif_uninit_irq(optee); in optee_smc_remove()
1332 optee_remove_common(optee); in optee_smc_remove()
1334 if (optee->smc.memremaped_shm) in optee_smc_remove()
1335 memunmap(optee->smc.memremaped_shm); in optee_smc_remove()
1337 kfree(optee); in optee_smc_remove()
1351 struct optee *optee = platform_get_drvdata(pdev); in optee_shutdown() local
1353 if (!optee->rpc_param_count) in optee_shutdown()
1354 optee_disable_shm_cache(optee); in optee_shutdown()
1361 struct optee *optee = NULL; in optee_probe() local
1443 optee = kzalloc(sizeof(*optee), GFP_KERNEL); in optee_probe()
1444 if (!optee) { in optee_probe()
1449 optee->ops = &optee_ops; in optee_probe()
1450 optee->smc.invoke_fn = invoke_fn; in optee_probe()
1451 optee->smc.sec_caps = sec_caps; in optee_probe()
1452 optee->rpc_param_count = rpc_param_count; in optee_probe()
1454 teedev = tee_device_alloc(&optee_clnt_desc, NULL, pool, optee); in optee_probe()
1459 optee->teedev = teedev; in optee_probe()
1461 teedev = tee_device_alloc(&optee_supp_desc, NULL, pool, optee); in optee_probe()
1466 optee->supp_teedev = teedev; in optee_probe()
1468 rc = tee_device_register(optee->teedev); in optee_probe()
1472 rc = tee_device_register(optee->supp_teedev); in optee_probe()
1476 mutex_init(&optee->call_queue.mutex); in optee_probe()
1477 INIT_LIST_HEAD(&optee->call_queue.waiters); in optee_probe()
1478 optee_supp_init(&optee->supp); in optee_probe()
1479 optee->smc.memremaped_shm = memremaped_shm; in optee_probe()
1480 optee->pool = pool; in optee_probe()
1481 optee_shm_arg_cache_init(optee, arg_cache_flags); in optee_probe()
1483 platform_set_drvdata(pdev, optee); in optee_probe()
1484 ctx = teedev_open(optee->teedev); in optee_probe()
1489 optee->ctx = ctx; in optee_probe()
1490 rc = optee_notif_init(optee, max_notif_value); in optee_probe()
1504 rc = optee_smc_notif_init_irq(optee, irq); in optee_probe()
1509 enable_async_notif(optee->smc.invoke_fn); in optee_probe()
1520 optee_disable_unmapped_shm_cache(optee); in optee_probe()
1526 if (!optee->rpc_param_count) in optee_probe()
1527 optee_enable_shm_cache(optee); in optee_probe()
1529 if (optee->smc.sec_caps & OPTEE_SMC_SEC_CAP_DYNAMIC_SHM) in optee_probe()
1540 if (!optee->rpc_param_count) in optee_probe()
1541 optee_disable_shm_cache(optee); in optee_probe()
1542 optee_smc_notif_uninit_irq(optee); in optee_probe()
1545 optee_notif_uninit(optee); in optee_probe()
1549 optee_shm_arg_cache_uninit(optee); in optee_probe()
1550 optee_supp_uninit(&optee->supp); in optee_probe()
1551 mutex_destroy(&optee->call_queue.mutex); in optee_probe()
1553 tee_device_unregister(optee->supp_teedev); in optee_probe()
1555 tee_device_unregister(optee->teedev); in optee_probe()
1557 kfree(optee); in optee_probe()