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
6969 return rc;
7070 }
7171
72+void 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+
7282 static void optee_bus_scan(struct work_struct *work)
7383 {
7484 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
379379 static void pool_ffa_op_free(struct tee_shm_pool *pool,
380380 struct tee_shm *shm)
381381 {
382− optee_ffa_shm_unregister(shm->ctx, shm);
383− free_pages((unsigned long)shm->kaddr, get_order(shm->size));
384− shm->kaddr = NULL;
382+ optee_pool_op_free_helper(pool, shm, optee_ffa_shm_unregister);
385383 }
386384
387385 static 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
236236 struct page **pages,
237237 size_t num_pages,
238238 unsigned long start));
239+void 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));
239242
240243
241244 void 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
558558 struct tee_shm *shm)
559559 {
560560 if (!(shm->flags & TEE_SHM_PRIV))
561− optee_shm_unregister(shm->ctx, shm);
562−
563− free_pages((unsigned long)shm->kaddr, get_order(shm->size));
564− shm->kaddr = NULL;
561+ optee_pool_op_free_helper(pool, shm, optee_shm_unregister);
562+ else
563+ optee_pool_op_free_helper(pool, shm, NULL);
565564 }
566565
567566 static 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