提交 924e3226 编写于 作者: J Jens Wiklander

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: NSumit Garg <sumit.garg@linaro.org>
Signed-off-by: NJens Wiklander <jens.wiklander@linaro.org>
上级 5d41f1b3
...@@ -69,6 +69,16 @@ int optee_pool_op_alloc_helper(struct tee_shm_pool *pool, struct tee_shm *shm, ...@@ -69,6 +69,16 @@ int optee_pool_op_alloc_helper(struct tee_shm_pool *pool, struct tee_shm *shm,
return rc; 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) static void optee_bus_scan(struct work_struct *work)
{ {
WARN_ON(optee_enumerate_devices(PTA_CMD_GET_DEVICES_SUPP)); WARN_ON(optee_enumerate_devices(PTA_CMD_GET_DEVICES_SUPP));
......
...@@ -379,9 +379,7 @@ static int pool_ffa_op_alloc(struct tee_shm_pool *pool, ...@@ -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, static void pool_ffa_op_free(struct tee_shm_pool *pool,
struct tee_shm *shm) struct tee_shm *shm)
{ {
optee_ffa_shm_unregister(shm->ctx, shm); optee_pool_op_free_helper(pool, shm, optee_ffa_shm_unregister);
free_pages((unsigned long)shm->kaddr, get_order(shm->size));
shm->kaddr = NULL;
} }
static void pool_ffa_op_destroy_pool(struct tee_shm_pool *pool) static void pool_ffa_op_destroy_pool(struct tee_shm_pool *pool)
......
...@@ -236,6 +236,9 @@ int optee_pool_op_alloc_helper(struct tee_shm_pool *pool, struct tee_shm *shm, ...@@ -236,6 +236,9 @@ int optee_pool_op_alloc_helper(struct tee_shm_pool *pool, struct tee_shm *shm,
struct page **pages, struct page **pages,
size_t num_pages, size_t num_pages,
unsigned long start)); 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); void optee_remove_common(struct optee *optee);
......
...@@ -558,10 +558,9 @@ static void pool_op_free(struct tee_shm_pool *pool, ...@@ -558,10 +558,9 @@ static void pool_op_free(struct tee_shm_pool *pool,
struct tee_shm *shm) struct tee_shm *shm)
{ {
if (!(shm->flags & TEE_SHM_PRIV)) if (!(shm->flags & TEE_SHM_PRIV))
optee_shm_unregister(shm->ctx, shm); optee_pool_op_free_helper(pool, shm, optee_shm_unregister);
else
free_pages((unsigned long)shm->kaddr, get_order(shm->size)); optee_pool_op_free_helper(pool, shm, NULL);
shm->kaddr = NULL;
} }
static void pool_op_destroy_pool(struct tee_shm_pool *pool) static void pool_op_destroy_pool(struct tee_shm_pool *pool)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册