Lines Matching full:optee

131  * @optee:	main service struct
137 static int optee_from_msg_param(struct optee *optee, struct tee_param *params, in optee_from_msg_param() argument
221 * @optee: main service struct
227 static int optee_to_msg_param(struct optee *optee, in optee_to_msg_param() argument
279 * @optee: main service struct
281 static void optee_enable_shm_cache(struct optee *optee) in optee_enable_shm_cache() argument
286 optee_cq_wait_init(&optee->call_queue, &w, false); in optee_enable_shm_cache()
290 optee->smc.invoke_fn(OPTEE_SMC_ENABLE_SHM_CACHE, in optee_enable_shm_cache()
294 optee_cq_wait_for_completion(&optee->call_queue, &w); in optee_enable_shm_cache()
296 optee_cq_wait_final(&optee->call_queue, &w); in optee_enable_shm_cache()
302 * @optee: main service struct
306 static void __optee_disable_shm_cache(struct optee *optee, bool is_mapped) in __optee_disable_shm_cache() argument
311 optee_cq_wait_init(&optee->call_queue, &w, false); in __optee_disable_shm_cache()
318 optee->smc.invoke_fn(OPTEE_SMC_DISABLE_SHM_CACHE, in __optee_disable_shm_cache()
336 optee_cq_wait_for_completion(&optee->call_queue, &w); in __optee_disable_shm_cache()
339 optee_cq_wait_final(&optee->call_queue, &w); in __optee_disable_shm_cache()
345 * @optee: main service struct
347 static void optee_disable_shm_cache(struct optee *optee) in optee_disable_shm_cache() argument
349 return __optee_disable_shm_cache(optee, true); in optee_disable_shm_cache()
356 * @optee: main service struct
358 static void optee_disable_unmapped_shm_cache(struct optee *optee) in optee_disable_unmapped_shm_cache() argument
360 return __optee_disable_shm_cache(optee, false); in optee_disable_unmapped_shm_cache()
456 struct optee *optee = tee_get_drvdata(ctx->teedev); in optee_shm_register() local
481 sz = optee_msg_arg_size(optee->rpc_param_count); in optee_shm_register()
510 if (optee->ops->do_call_with_arg(ctx, shm_arg, 0, false) || in optee_shm_register()
522 struct optee *optee = tee_get_drvdata(ctx->teedev); in optee_shm_unregister() local
537 sz = optee_msg_arg_size(optee->rpc_param_count); in optee_shm_unregister()
553 if (optee->ops->do_call_with_arg(ctx, shm_arg, 0, false) || in optee_shm_unregister()
677 struct optee *optee, in handle_rpc_func_cmd_shm_alloc() argument
708 shm = tee_shm_alloc_priv_buf(optee->ctx, sz); in handle_rpc_func_cmd_shm_alloc()
785 static void handle_rpc_func_cmd(struct tee_context *ctx, struct optee *optee, in handle_rpc_func_cmd() argument
793 handle_rpc_func_cmd_shm_alloc(ctx, optee, arg, call_ctx); in handle_rpc_func_cmd()
799 optee_rpc_cmd(ctx, optee, arg); in handle_rpc_func_cmd()
818 struct optee *optee = tee_get_drvdata(teedev); in optee_handle_rpc() local
825 shm = tee_shm_alloc_priv_buf(optee->ctx, param->a1); in optee_handle_rpc()
863 handle_rpc_func_cmd(ctx, optee, arg, call_ctx); in optee_handle_rpc()
890 struct optee *optee = tee_get_drvdata(ctx->teedev); in optee_smc_do_call_with_arg() local
897 if (optee->rpc_param_count) { in optee_smc_do_call_with_arg()
929 optee_cq_wait_init(&optee->call_queue, &w, system_thread); in optee_smc_do_call_with_arg()
934 optee->smc.invoke_fn(param.a0, param.a1, param.a2, param.a3, in optee_smc_do_call_with_arg()
944 optee_cq_wait_for_completion(&optee->call_queue, &w); in optee_smc_do_call_with_arg()
963 optee_cq_wait_final(&optee->call_queue, &w); in optee_smc_do_call_with_arg()
988 static irqreturn_t irq_handler(struct optee *optee) in irq_handler() argument
996 value = get_async_notif_value(optee->smc.invoke_fn, in irq_handler()
1004 optee_notif_send(optee, value); in irq_handler()
1014 struct optee *optee = dev_id; in notif_irq_handler() local
1016 return irq_handler(optee); in notif_irq_handler()
1021 struct optee *optee = dev_id; in notif_irq_thread_fn() local
1023 optee_do_bottom_half(optee->ctx); in notif_irq_thread_fn()
1028 static int init_irq(struct optee *optee, u_int irq) in init_irq() argument
1034 0, "optee_notification", optee); in init_irq()
1038 optee->smc.notif_irq = irq; in init_irq()
1046 struct optee *optee = pcpu->optee; in notif_pcpu_irq_handler() local
1048 if (irq_handler(optee) == IRQ_WAKE_THREAD) in notif_pcpu_irq_handler()
1049 queue_work(optee->smc.notif_pcpu_wq, in notif_pcpu_irq_handler()
1050 &optee->smc.notif_pcpu_work); in notif_pcpu_irq_handler()
1059 struct optee *optee = container_of(optee_smc, struct optee, smc); in notif_pcpu_irq_work_fn() local
1061 optee_do_bottom_half(optee->ctx); in notif_pcpu_irq_work_fn()
1064 static int init_pcpu_irq(struct optee *optee, u_int irq) in init_pcpu_irq() argument
1074 per_cpu_ptr(optee_pcpu, cpu)->optee = optee; in init_pcpu_irq()
1081 INIT_WORK(&optee->smc.notif_pcpu_work, notif_pcpu_irq_work_fn); in init_pcpu_irq()
1082 optee->smc.notif_pcpu_wq = create_workqueue("optee_pcpu_notification"); in init_pcpu_irq()
1083 if (!optee->smc.notif_pcpu_wq) { in init_pcpu_irq()
1088 optee->smc.optee_pcpu = optee_pcpu; in init_pcpu_irq()
1089 optee->smc.notif_irq = irq; in init_pcpu_irq()
1092 rc = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "optee/pcpu-notif:starting", in init_pcpu_irq()
1100 optee->smc.notif_cpuhp_state = rc; in init_pcpu_irq()
1112 static int optee_smc_notif_init_irq(struct optee *optee, u_int irq) in optee_smc_notif_init_irq() argument
1115 return init_pcpu_irq(optee, irq); in optee_smc_notif_init_irq()
1117 return init_irq(optee, irq); in optee_smc_notif_init_irq()
1120 static void uninit_pcpu_irq(struct optee *optee) in uninit_pcpu_irq() argument
1122 cpuhp_remove_state(optee->smc.notif_cpuhp_state); in uninit_pcpu_irq()
1124 destroy_workqueue(optee->smc.notif_pcpu_wq); in uninit_pcpu_irq()
1126 free_percpu_irq(optee->smc.notif_irq, optee->smc.optee_pcpu); in uninit_pcpu_irq()
1127 free_percpu(optee->smc.optee_pcpu); in uninit_pcpu_irq()
1130 static void optee_smc_notif_uninit_irq(struct optee *optee) in optee_smc_notif_uninit_irq() argument
1132 if (optee->smc.sec_caps & OPTEE_SMC_SEC_CAP_ASYNC_NOTIF) { in optee_smc_notif_uninit_irq()
1133 optee_stop_async_notif(optee->ctx); in optee_smc_notif_uninit_irq()
1134 if (optee->smc.notif_irq) { in optee_smc_notif_uninit_irq()
1135 if (irq_is_percpu_devid(optee->smc.notif_irq)) in optee_smc_notif_uninit_irq()
1136 uninit_pcpu_irq(optee); in optee_smc_notif_uninit_irq()
1138 free_irq(optee->smc.notif_irq, optee); in optee_smc_notif_uninit_irq()
1140 irq_dispose_mapping(optee->smc.notif_irq); in optee_smc_notif_uninit_irq()
1162 struct optee *optee = tee_get_drvdata(teedev); in optee_get_version() local
1164 if (optee->smc.sec_caps & OPTEE_SMC_SEC_CAP_DYNAMIC_SHM) in optee_get_version()
1166 if (optee->smc.sec_caps & OPTEE_SMC_SEC_CAP_MEMREF_NULL) in optee_get_version()
1173 struct optee *optee = tee_get_drvdata(ctx->teedev); in optee_smc_open() local
1174 u32 sec_caps = optee->smc.sec_caps; in optee_smc_open()
1438 struct optee *optee = platform_get_drvdata(pdev); in optee_smc_remove() local
1445 if (!optee->rpc_param_count) in optee_smc_remove()
1446 optee_disable_shm_cache(optee); in optee_smc_remove()
1448 optee_smc_notif_uninit_irq(optee); in optee_smc_remove()
1450 optee_remove_common(optee); in optee_smc_remove()
1452 if (optee->smc.memremaped_shm) in optee_smc_remove()
1453 memunmap(optee->smc.memremaped_shm); in optee_smc_remove()
1455 kfree(optee); in optee_smc_remove()
1469 struct optee *optee = platform_get_drvdata(pdev); in optee_shutdown() local
1471 if (!optee->rpc_param_count) in optee_shutdown()
1472 optee_disable_shm_cache(optee); in optee_shutdown()
1477 #define OPTEE_FW_IMAGE "optee/tee.bin"
1568 hp_state = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "optee:probe", in optee_load_fw()
1592 struct optee *optee = NULL; in optee_probe() local
1680 optee = kzalloc(sizeof(*optee), GFP_KERNEL); in optee_probe()
1681 if (!optee) { in optee_probe()
1686 optee->ops = &optee_ops; in optee_probe()
1687 optee->smc.invoke_fn = invoke_fn; in optee_probe()
1688 optee->smc.sec_caps = sec_caps; in optee_probe()
1689 optee->rpc_param_count = rpc_param_count; in optee_probe()
1691 teedev = tee_device_alloc(&optee_clnt_desc, NULL, pool, optee); in optee_probe()
1696 optee->teedev = teedev; in optee_probe()
1698 teedev = tee_device_alloc(&optee_supp_desc, NULL, pool, optee); in optee_probe()
1703 optee->supp_teedev = teedev; in optee_probe()
1705 rc = tee_device_register(optee->teedev); in optee_probe()
1709 rc = tee_device_register(optee->supp_teedev); in optee_probe()
1713 optee_cq_init(&optee->call_queue, thread_count); in optee_probe()
1714 optee_supp_init(&optee->supp); in optee_probe()
1715 optee->smc.memremaped_shm = memremaped_shm; in optee_probe()
1716 optee->pool = pool; in optee_probe()
1717 optee_shm_arg_cache_init(optee, arg_cache_flags); in optee_probe()
1719 platform_set_drvdata(pdev, optee); in optee_probe()
1720 ctx = teedev_open(optee->teedev); in optee_probe()
1725 optee->ctx = ctx; in optee_probe()
1726 rc = optee_notif_init(optee, max_notif_value); in optee_probe()
1740 rc = optee_smc_notif_init_irq(optee, irq); in optee_probe()
1745 enable_async_notif(optee->smc.invoke_fn); in optee_probe()
1756 optee_disable_unmapped_shm_cache(optee); in optee_probe()
1762 if (!optee->rpc_param_count) in optee_probe()
1763 optee_enable_shm_cache(optee); in optee_probe()
1765 if (optee->smc.sec_caps & OPTEE_SMC_SEC_CAP_DYNAMIC_SHM) in optee_probe()
1776 if (!optee->rpc_param_count) in optee_probe()
1777 optee_disable_shm_cache(optee); in optee_probe()
1778 optee_smc_notif_uninit_irq(optee); in optee_probe()
1781 optee_notif_uninit(optee); in optee_probe()
1785 optee_shm_arg_cache_uninit(optee); in optee_probe()
1786 optee_supp_uninit(&optee->supp); in optee_probe()
1787 mutex_destroy(&optee->call_queue.mutex); in optee_probe()
1789 tee_device_unregister(optee->supp_teedev); in optee_probe()
1791 tee_device_unregister(optee->teedev); in optee_probe()
1793 kfree(optee); in optee_probe()
1802 { .compatible = "linaro,optee-tz" },
1812 .name = "optee",