ffa_abi.c (8c3812c8f74f050278d734ec4b90149d84bdbefb) ffa_abi.c (7aa7a97989557011f762a4b7c2e4e3b061b638e4)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (c) 2021, Linaro Limited
4 */
5
6#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
7
8#include <linux/arm_ffa.h>

--- 258 unchanged lines hidden (view full) ---

267 */
268
269static int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm,
270 struct page **pages, size_t num_pages,
271 unsigned long start)
272{
273 struct optee *optee = tee_get_drvdata(ctx->teedev);
274 struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (c) 2021, Linaro Limited
4 */
5
6#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
7
8#include <linux/arm_ffa.h>

--- 258 unchanged lines hidden (view full) ---

267 */
268
269static int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm,
270 struct page **pages, size_t num_pages,
271 unsigned long start)
272{
273 struct optee *optee = tee_get_drvdata(ctx->teedev);
274 struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
275 const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
275 const struct ffa_ops *ffa_ops = ffa_dev->ops;
276 struct ffa_mem_region_attributes mem_attr = {
277 .receiver = ffa_dev->vm_id,
278 .attrs = FFA_MEM_RW,
279 };
280 struct ffa_mem_ops_args args = {
281 .use_txbuf = true,
282 .attrs = &mem_attr,
283 .nattrs = 1,

--- 26 unchanged lines hidden (view full) ---

310 return 0;
311}
312
313static int optee_ffa_shm_unregister(struct tee_context *ctx,
314 struct tee_shm *shm)
315{
316 struct optee *optee = tee_get_drvdata(ctx->teedev);
317 struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
276 struct ffa_mem_region_attributes mem_attr = {
277 .receiver = ffa_dev->vm_id,
278 .attrs = FFA_MEM_RW,
279 };
280 struct ffa_mem_ops_args args = {
281 .use_txbuf = true,
282 .attrs = &mem_attr,
283 .nattrs = 1,

--- 26 unchanged lines hidden (view full) ---

310 return 0;
311}
312
313static int optee_ffa_shm_unregister(struct tee_context *ctx,
314 struct tee_shm *shm)
315{
316 struct optee *optee = tee_get_drvdata(ctx->teedev);
317 struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
318 const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
318 const struct ffa_ops *ffa_ops = ffa_dev->ops;
319 u64 global_handle = shm->sec_world_id;
320 struct ffa_send_direct_data data = {
321 .data0 = OPTEE_FFA_UNREGISTER_SHM,
322 .data1 = (u32)global_handle,
323 .data2 = (u32)(global_handle >> 32)
324 };
325 int rc;
326

--- 10 unchanged lines hidden (view full) ---

337
338 return rc;
339}
340
341static int optee_ffa_shm_unregister_supp(struct tee_context *ctx,
342 struct tee_shm *shm)
343{
344 struct optee *optee = tee_get_drvdata(ctx->teedev);
319 u64 global_handle = shm->sec_world_id;
320 struct ffa_send_direct_data data = {
321 .data0 = OPTEE_FFA_UNREGISTER_SHM,
322 .data1 = (u32)global_handle,
323 .data2 = (u32)(global_handle >> 32)
324 };
325 int rc;
326

--- 10 unchanged lines hidden (view full) ---

337
338 return rc;
339}
340
341static int optee_ffa_shm_unregister_supp(struct tee_context *ctx,
342 struct tee_shm *shm)
343{
344 struct optee *optee = tee_get_drvdata(ctx->teedev);
345 const struct ffa_dev_ops *ffa_ops = optee->ffa.ffa_dev->ops;
345 const struct ffa_ops *ffa_ops = optee->ffa.ffa_dev->ops;
346 u64 global_handle = shm->sec_world_id;
347 int rc;
348
349 /*
350 * We're skipping the OPTEE_FFA_YIELDING_CALL_UNREGISTER_SHM call
351 * since this is OP-TEE freeing via RPC so it has already retired
352 * this ID.
353 */

--- 171 unchanged lines hidden (view full) ---

525}
526
527static int optee_ffa_yielding_call(struct tee_context *ctx,
528 struct ffa_send_direct_data *data,
529 struct optee_msg_arg *rpc_arg)
530{
531 struct optee *optee = tee_get_drvdata(ctx->teedev);
532 struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
346 u64 global_handle = shm->sec_world_id;
347 int rc;
348
349 /*
350 * We're skipping the OPTEE_FFA_YIELDING_CALL_UNREGISTER_SHM call
351 * since this is OP-TEE freeing via RPC so it has already retired
352 * this ID.
353 */

--- 171 unchanged lines hidden (view full) ---

525}
526
527static int optee_ffa_yielding_call(struct tee_context *ctx,
528 struct ffa_send_direct_data *data,
529 struct optee_msg_arg *rpc_arg)
530{
531 struct optee *optee = tee_get_drvdata(ctx->teedev);
532 struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
533 const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
533 const struct ffa_ops *ffa_ops = ffa_dev->ops;
534 struct optee_call_waiter w;
535 u32 cmd = data->data0;
536 u32 w4 = data->data1;
537 u32 w5 = data->data2;
538 u32 w6 = data->data3;
539 int rc;
540
541 /* Initialize waiter */

--- 105 unchanged lines hidden (view full) ---

647 * 6. Driver initialization
648 *
649 * During driver inititialization is the OP-TEE Secure Partition is probed
650 * to find out which features it supports so the driver can be initialized
651 * with a matching configuration.
652 */
653
654static bool optee_ffa_api_is_compatbile(struct ffa_device *ffa_dev,
534 struct optee_call_waiter w;
535 u32 cmd = data->data0;
536 u32 w4 = data->data1;
537 u32 w5 = data->data2;
538 u32 w6 = data->data3;
539 int rc;
540
541 /* Initialize waiter */

--- 105 unchanged lines hidden (view full) ---

647 * 6. Driver initialization
648 *
649 * During driver inititialization is the OP-TEE Secure Partition is probed
650 * to find out which features it supports so the driver can be initialized
651 * with a matching configuration.
652 */
653
654static bool optee_ffa_api_is_compatbile(struct ffa_device *ffa_dev,
655 const struct ffa_dev_ops *ops)
655 const struct ffa_ops *ops)
656{
657 struct ffa_send_direct_data data = { OPTEE_FFA_GET_API_VERSION };
658 int rc;
659
660 ops->mode_32bit_set(ffa_dev);
661
662 rc = ops->sync_send_receive(ffa_dev, &data);
663 if (rc) {

--- 18 unchanged lines hidden (view full) ---

682 data.data0, data.data1, data.data2);
683 else
684 pr_info("revision %lu.%lu", data.data0, data.data1);
685
686 return true;
687}
688
689static bool optee_ffa_exchange_caps(struct ffa_device *ffa_dev,
656{
657 struct ffa_send_direct_data data = { OPTEE_FFA_GET_API_VERSION };
658 int rc;
659
660 ops->mode_32bit_set(ffa_dev);
661
662 rc = ops->sync_send_receive(ffa_dev, &data);
663 if (rc) {

--- 18 unchanged lines hidden (view full) ---

682 data.data0, data.data1, data.data2);
683 else
684 pr_info("revision %lu.%lu", data.data0, data.data1);
685
686 return true;
687}
688
689static bool optee_ffa_exchange_caps(struct ffa_device *ffa_dev,
690 const struct ffa_dev_ops *ops,
690 const struct ffa_ops *ops,
691 u32 *sec_caps,
692 unsigned int *rpc_param_count)
693{
694 struct ffa_send_direct_data data = { OPTEE_FFA_EXCHANGE_CAPABILITIES };
695 int rc;
696
697 rc = ops->sync_send_receive(ffa_dev, &data);
698 if (rc) {

--- 79 unchanged lines hidden (view full) ---

778 mutex_destroy(&optee->ffa.mutex);
779 rhashtable_free_and_destroy(&optee->ffa.global_ids, rh_free_fn, NULL);
780
781 kfree(optee);
782}
783
784static int optee_ffa_probe(struct ffa_device *ffa_dev)
785{
691 u32 *sec_caps,
692 unsigned int *rpc_param_count)
693{
694 struct ffa_send_direct_data data = { OPTEE_FFA_EXCHANGE_CAPABILITIES };
695 int rc;
696
697 rc = ops->sync_send_receive(ffa_dev, &data);
698 if (rc) {

--- 79 unchanged lines hidden (view full) ---

778 mutex_destroy(&optee->ffa.mutex);
779 rhashtable_free_and_destroy(&optee->ffa.global_ids, rh_free_fn, NULL);
780
781 kfree(optee);
782}
783
784static int optee_ffa_probe(struct ffa_device *ffa_dev)
785{
786 const struct ffa_dev_ops *ffa_ops;
786 const struct ffa_ops *ffa_ops;
787 unsigned int rpc_param_count;
788 struct tee_shm_pool *pool;
789 struct tee_device *teedev;
790 struct tee_context *ctx;
791 u32 arg_cache_flags = 0;
792 struct optee *optee;
793 u32 sec_caps;
794 int rc;

--- 125 unchanged lines hidden ---
787 unsigned int rpc_param_count;
788 struct tee_shm_pool *pool;
789 struct tee_device *teedev;
790 struct tee_context *ctx;
791 u32 arg_cache_flags = 0;
792 struct optee *optee;
793 u32 sec_caps;
794 int rc;

--- 125 unchanged lines hidden ---