Lines Matching defs:optee

131  * @optee:	main service struct
137 static int optee_from_msg_param(struct optee *optee, struct tee_param *params,
221 * @optee: main service struct
227 static int optee_to_msg_param(struct optee *optee,
279 * @optee: main service struct
281 static void optee_enable_shm_cache(struct optee *optee)
286 optee_cq_wait_init(&optee->call_queue, &w);
290 optee->smc.invoke_fn(OPTEE_SMC_ENABLE_SHM_CACHE,
294 optee_cq_wait_for_completion(&optee->call_queue, &w);
296 optee_cq_wait_final(&optee->call_queue, &w);
302 * @optee: main service struct
306 static void __optee_disable_shm_cache(struct optee *optee, bool is_mapped)
311 optee_cq_wait_init(&optee->call_queue, &w);
318 optee->smc.invoke_fn(OPTEE_SMC_DISABLE_SHM_CACHE,
336 optee_cq_wait_for_completion(&optee->call_queue, &w);
339 optee_cq_wait_final(&optee->call_queue, &w);
345 * @optee: main service struct
347 static void optee_disable_shm_cache(struct optee *optee)
349 return __optee_disable_shm_cache(optee, true);
356 * @optee: main service struct
358 static void optee_disable_unmapped_shm_cache(struct optee *optee)
360 return __optee_disable_shm_cache(optee, false);
456 struct optee *optee = tee_get_drvdata(ctx->teedev);
481 sz = optee_msg_arg_size(optee->rpc_param_count);
510 if (optee->ops->do_call_with_arg(ctx, shm_arg, 0) ||
522 struct optee *optee = tee_get_drvdata(ctx->teedev);
537 sz = optee_msg_arg_size(optee->rpc_param_count);
553 if (optee->ops->do_call_with_arg(ctx, shm_arg, 0) ||
677 struct optee *optee,
707 shm = tee_shm_alloc_priv_buf(optee->ctx, sz);
788 static void handle_rpc_func_cmd(struct tee_context *ctx, struct optee *optee,
796 handle_rpc_func_cmd_shm_alloc(ctx, optee, arg, call_ctx);
802 optee_rpc_cmd(ctx, optee, arg);
820 struct optee *optee = tee_get_drvdata(teedev);
827 shm = tee_shm_alloc_priv_buf(optee->ctx, param->a1);
865 handle_rpc_func_cmd(ctx, optee, arg, call_ctx);
890 struct optee *optee = tee_get_drvdata(ctx->teedev);
897 if (optee->rpc_param_count) {
929 optee_cq_wait_init(&optee->call_queue, &w);
934 optee->smc.invoke_fn(param.a0, param.a1, param.a2, param.a3,
944 optee_cq_wait_for_completion(&optee->call_queue, &w);
963 optee_cq_wait_final(&optee->call_queue, &w);
1016 static irqreturn_t irq_handler(struct optee *optee)
1024 value = get_async_notif_value(optee->smc.invoke_fn,
1032 optee_notif_send(optee, value);
1042 struct optee *optee = dev_id;
1044 return irq_handler(optee);
1049 struct optee *optee = dev_id;
1051 optee_smc_do_bottom_half(optee->ctx);
1056 static int init_irq(struct optee *optee, u_int irq)
1062 0, "optee_notification", optee);
1066 optee->smc.notif_irq = irq;
1074 struct optee *optee = pcpu->optee;
1076 if (irq_handler(optee) == IRQ_WAKE_THREAD)
1077 queue_work(optee->smc.notif_pcpu_wq,
1078 &optee->smc.notif_pcpu_work);
1087 struct optee *optee = container_of(optee_smc, struct optee, smc);
1089 optee_smc_do_bottom_half(optee->ctx);
1092 static int init_pcpu_irq(struct optee *optee, u_int irq)
1102 per_cpu_ptr(optee_pcpu, cpu)->optee = optee;
1109 INIT_WORK(&optee->smc.notif_pcpu_work, notif_pcpu_irq_work_fn);
1110 optee->smc.notif_pcpu_wq = create_workqueue("optee_pcpu_notification");
1111 if (!optee->smc.notif_pcpu_wq) {
1116 optee->smc.optee_pcpu = optee_pcpu;
1117 optee->smc.notif_irq = irq;
1120 rc = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "optee/pcpu-notif:starting",
1128 optee->smc.notif_cpuhp_state = rc;
1140 static int optee_smc_notif_init_irq(struct optee *optee, u_int irq)
1143 return init_pcpu_irq(optee, irq);
1145 return init_irq(optee, irq);
1148 static void uninit_pcpu_irq(struct optee *optee)
1150 cpuhp_remove_state(optee->smc.notif_cpuhp_state);
1152 destroy_workqueue(optee->smc.notif_pcpu_wq);
1154 free_percpu_irq(optee->smc.notif_irq, optee->smc.optee_pcpu);
1155 free_percpu(optee->smc.optee_pcpu);
1158 static void optee_smc_notif_uninit_irq(struct optee *optee)
1160 if (optee->smc.sec_caps & OPTEE_SMC_SEC_CAP_ASYNC_NOTIF) {
1161 optee_smc_stop_async_notif(optee->ctx);
1162 if (optee->smc.notif_irq) {
1163 if (irq_is_percpu_devid(optee->smc.notif_irq))
1164 uninit_pcpu_irq(optee);
1166 free_irq(optee->smc.notif_irq, optee);
1168 irq_dispose_mapping(optee->smc.notif_irq);
1190 struct optee *optee = tee_get_drvdata(teedev);
1192 if (optee->smc.sec_caps & OPTEE_SMC_SEC_CAP_DYNAMIC_SHM)
1194 if (optee->smc.sec_caps & OPTEE_SMC_SEC_CAP_MEMREF_NULL)
1201 struct optee *optee = tee_get_drvdata(ctx->teedev);
1202 u32 sec_caps = optee->smc.sec_caps;
1455 struct optee *optee = platform_get_drvdata(pdev);
1462 if (!optee->rpc_param_count)
1463 optee_disable_shm_cache(optee);
1465 optee_smc_notif_uninit_irq(optee);
1467 optee_remove_common(optee);
1469 if (optee->smc.memremaped_shm)
1470 memunmap(optee->smc.memremaped_shm);
1472 kfree(optee);
1486 struct optee *optee = platform_get_drvdata(pdev);
1488 if (!optee->rpc_param_count)
1489 optee_disable_shm_cache(optee);
1494 #define OPTEE_FW_IMAGE "optee/tee.bin"
1585 hp_state = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "optee:probe",
1609 struct optee *optee = NULL;
1695 optee = kzalloc(sizeof(*optee), GFP_KERNEL);
1696 if (!optee) {
1701 optee->ops = &optee_ops;
1702 optee->smc.invoke_fn = invoke_fn;
1703 optee->smc.sec_caps = sec_caps;
1704 optee->rpc_param_count = rpc_param_count;
1706 teedev = tee_device_alloc(&optee_clnt_desc, NULL, pool, optee);
1711 optee->teedev = teedev;
1713 teedev = tee_device_alloc(&optee_supp_desc, NULL, pool, optee);
1718 optee->supp_teedev = teedev;
1720 rc = tee_device_register(optee->teedev);
1724 rc = tee_device_register(optee->supp_teedev);
1728 mutex_init(&optee->call_queue.mutex);
1729 INIT_LIST_HEAD(&optee->call_queue.waiters);
1730 optee_supp_init(&optee->supp);
1731 optee->smc.memremaped_shm = memremaped_shm;
1732 optee->pool = pool;
1733 optee_shm_arg_cache_init(optee, arg_cache_flags);
1735 platform_set_drvdata(pdev, optee);
1736 ctx = teedev_open(optee->teedev);
1741 optee->ctx = ctx;
1742 rc = optee_notif_init(optee, max_notif_value);
1756 rc = optee_smc_notif_init_irq(optee, irq);
1761 enable_async_notif(optee->smc.invoke_fn);
1772 optee_disable_unmapped_shm_cache(optee);
1778 if (!optee->rpc_param_count)
1779 optee_enable_shm_cache(optee);
1781 if (optee->smc.sec_caps & OPTEE_SMC_SEC_CAP_DYNAMIC_SHM)
1792 if (!optee->rpc_param_count)
1793 optee_disable_shm_cache(optee);
1794 optee_smc_notif_uninit_irq(optee);
1797 optee_notif_uninit(optee);
1801 optee_shm_arg_cache_uninit(optee);
1802 optee_supp_uninit(&optee->supp);
1803 mutex_destroy(&optee->call_queue.mutex);
1805 tee_device_unregister(optee->supp_teedev);
1807 tee_device_unregister(optee->teedev);
1809 kfree(optee);
1818 { .compatible = "linaro,optee-tz" },
1828 .name = "optee",