History

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().

Jens Wiklander committed 4 years ago

Commit 924e3221 parent 5d41f1b4 files · +17 −7Browse files

Unified · Split

4 files
  1. drivers/tee/optee/core.c +10 −0
  2. drivers/tee/optee/ffa_abi.c +1 −3
  3. drivers/tee/optee/optee_private.h +3 −0
  4. drivers/tee/optee/smc_abi.c +3 −4
drivers/tee/optee/core.c+10−0
@@ -69,6 +69,16 @@ err: · 68 unmodified lines
69 return rc;69 return rc;
70}70}
71 71
72void optee_pool_op_free_helper(struct tee_shm_pool *pool, struct tee_shm *shm,
73 int (*shm_unregister)(struct tee_context *ctx,
74 struct tee_shm *shm))
75{
76 if (shm_unregister)
77 shm_unregister(shm->ctx, shm);
78 free_pages((unsigned long)shm->kaddr, get_order(shm->size));
79 shm->kaddr = NULL;
80}
81
72static void optee_bus_scan(struct work_struct *work)82static void optee_bus_scan(struct work_struct *work)
73{83{
74 WARN_ON(optee_enumerate_devices(PTA_CMD_GET_DEVICES_SUPP));84 WARN_ON(optee_enumerate_devices(PTA_CMD_GET_DEVICES_SUPP));
drivers/tee/optee/ffa_abi.c+1−3
@@ -379,9 +379,7 @@ static int pool_ffa_op_alloc(struct tee_shm_pool *pool, · 378 unmodified lines
379static void pool_ffa_op_free(struct tee_shm_pool *pool,379static void pool_ffa_op_free(struct tee_shm_pool *pool,
380 struct tee_shm *shm)380 struct tee_shm *shm)
381{381{
382 optee_ffa_shm_unregister(shm->ctx, shm);382 optee_pool_op_free_helper(pool, shm, optee_ffa_shm_unregister);
383 free_pages((unsigned long)shm->kaddr, get_order(shm->size));
384 shm->kaddr = NULL;
385}383}
386 384
387static void pool_ffa_op_destroy_pool(struct tee_shm_pool *pool)385static void pool_ffa_op_destroy_pool(struct tee_shm_pool *pool)
drivers/tee/optee/optee_private.h+3−0
@@ -236,6 +236,9 @@ int optee_pool_op_alloc_helper(struct tee_shm_pool *pool, struct tee_shm *shm, · 235 unmodified lines
236 struct page **pages,236 struct page **pages,
237 size_t num_pages,237 size_t num_pages,
238 unsigned long start));238 unsigned long start));
239void optee_pool_op_free_helper(struct tee_shm_pool *pool, struct tee_shm *shm,
240 int (*shm_unregister)(struct tee_context *ctx,
241 struct tee_shm *shm));
239 242
240 243
241void optee_remove_common(struct optee *optee);244void optee_remove_common(struct optee *optee);
drivers/tee/optee/smc_abi.c+3−4
@@ -558,10 +558,9 @@ static void pool_op_free(struct tee_shm_pool *pool, · 557 unmodified lines
558 struct tee_shm *shm)558 struct tee_shm *shm)
559{559{
560 if (!(shm->flags & TEE_SHM_PRIV))560 if (!(shm->flags & TEE_SHM_PRIV))
561 optee_shm_unregister(shm->ctx, shm);561 optee_pool_op_free_helper(pool, shm, optee_shm_unregister);
562 562 else
563 free_pages((unsigned long)shm->kaddr, get_order(shm->size));563 optee_pool_op_free_helper(pool, shm, NULL);
564 shm->kaddr = NULL;
565}564}
566 565
567static void pool_op_destroy_pool(struct tee_shm_pool *pool)566static void pool_op_destroy_pool(struct tee_shm_pool *pool)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t