diff options
author | Jens Wiklander <jens.wiklander@linaro.org> | 2022-02-04 10:33:55 +0100 |
---|---|---|
committer | Jens Wiklander <jens.wiklander@linaro.org> | 2022-02-16 07:49:41 +0100 |
commit | 924e32269228a4e2575e50e6fd6ed83cb57aa52a (patch) | |
tree | d34f9fa198c09c11dad0c74fb4b9e3e264e94dc9 /drivers | |
parent | 5d41f1b3e3282909b6bbceacb9aebe1d3c849a49 (diff) |
optee: add optee_pool_op_free_helper()
Adds a common helper function to free a tee_shm allocated using the
helper function optee_pool_op_alloc_helper().
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/tee/optee/core.c | 10 | ||||
-rw-r--r-- | drivers/tee/optee/ffa_abi.c | 4 | ||||
-rw-r--r-- | drivers/tee/optee/optee_private.h | 3 | ||||
-rw-r--r-- | drivers/tee/optee/smc_abi.c | 7 |
4 files changed, 17 insertions, 7 deletions
diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c index f4bccb5f0e93..daf947e98d14 100644 --- a/drivers/tee/optee/core.c +++ b/drivers/tee/optee/core.c @@ -69,6 +69,16 @@ err: return rc; } +void optee_pool_op_free_helper(struct tee_shm_pool *pool, struct tee_shm *shm, + int (*shm_unregister)(struct tee_context *ctx, + struct tee_shm *shm)) +{ + if (shm_unregister) + shm_unregister(shm->ctx, shm); + free_pages((unsigned long)shm->kaddr, get_order(shm->size)); + shm->kaddr = NULL; +} + static void optee_bus_scan(struct work_struct *work) { WARN_ON(optee_enumerate_devices(PTA_CMD_GET_DEVICES_SUPP)); diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c index fb7345941024..8cd9c70a9268 100644 --- a/drivers/tee/optee/ffa_abi.c +++ b/drivers/tee/optee/ffa_abi.c @@ -379,9 +379,7 @@ static int pool_ffa_op_alloc(struct tee_shm_pool *pool, static void pool_ffa_op_free(struct tee_shm_pool *pool, struct tee_shm *shm) { - optee_ffa_shm_unregister(shm->ctx, shm); - free_pages((unsigned long)shm->kaddr, get_order(shm->size)); - shm->kaddr = NULL; + optee_pool_op_free_helper(pool, shm, optee_ffa_shm_unregister); } static void pool_ffa_op_destroy_pool(struct tee_shm_pool *pool) diff --git a/drivers/tee/optee/optee_private.h b/drivers/tee/optee/optee_private.h index df3a483bbf46..e77765c78878 100644 --- a/drivers/tee/optee/optee_private.h +++ b/drivers/tee/optee/optee_private.h @@ -236,6 +236,9 @@ int optee_pool_op_alloc_helper(struct tee_shm_pool *pool, struct tee_shm *shm, struct page **pages, size_t num_pages, unsigned long start)); +void optee_pool_op_free_helper(struct tee_shm_pool *pool, struct tee_shm *shm, + int (*shm_unregister)(struct tee_context *ctx, + struct tee_shm *shm)); void optee_remove_common(struct optee *optee); diff --git a/drivers/tee/optee/smc_abi.c b/drivers/tee/optee/smc_abi.c index 7580d52b3852..ef3e27b602e6 100644 --- a/drivers/tee/optee/smc_abi.c +++ b/drivers/tee/optee/smc_abi.c @@ -558,10 +558,9 @@ static void pool_op_free(struct tee_shm_pool *pool, struct tee_shm *shm) { if (!(shm->flags & TEE_SHM_PRIV)) - optee_shm_unregister(shm->ctx, shm); - - free_pages((unsigned long)shm->kaddr, get_order(shm->size)); - shm->kaddr = NULL; + optee_pool_op_free_helper(pool, shm, optee_shm_unregister); + else + optee_pool_op_free_helper(pool, shm, NULL); } static void pool_op_destroy_pool(struct tee_shm_pool *pool) |