Skip to content

Commit

Permalink
tee: add helper method to increase the refcount on an SHM
Browse files Browse the repository at this point in the history
At times, it may be useful to allow a caller to increase the reference
count on a shared memory (SHM) object at will. This patch adds tee_shm_get,
the increasing counterpart to tee_shm_put.

Signed-off-by: Hernan Gatta <[email protected]>
Reviewed-by: Jens Wiklander <[email protected]>
Acked-by: Etienne Carriere <[email protected]>
[etienne: picked commit from linaro-swg/linux#72]
Signed-off-by: Etienne Carriere <[email protected]>
Change-Id: I4ec1ef1f3a44b9000ef26717a52853cecd3fcaa3
  • Loading branch information
etienne-lms authored and fourmone committed Mar 25, 2022
1 parent 2aa2627 commit 9061b6f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/tee/tee_shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,17 @@ struct tee_shm *tee_shm_get_from_id(struct tee_context *ctx, int id)
}
EXPORT_SYMBOL_GPL(tee_shm_get_from_id);

/**
* tee_shm_get() - Increase reference count on a shared memory handle
* @shm: Shared memory handle
*/
void tee_shm_get(struct tee_shm *shm)
{
if (shm->flags & TEE_SHM_DMA_BUF)
get_dma_buf(shm->dmabuf);
}
EXPORT_SYMBOL_GPL(tee_shm_get);

/**
* tee_shm_put() - Decrease reference count on a shared memory handle
* @shm: Shared memory handle
Expand Down
6 changes: 6 additions & 0 deletions include/linux/tee_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,12 @@ static inline bool tee_shm_is_registered(struct tee_shm *shm)
*/
void tee_shm_free(struct tee_shm *shm);

/**
* tee_shm_get() - Increase reference count on a shared memory handle
* @shm: Shared memory handle
*/
void tee_shm_get(struct tee_shm *shm);

/**
* tee_shm_put() - Decrease reference count on a shared memory handle
* @shm: Shared memory handle
Expand Down

0 comments on commit 9061b6f

Please sign in to comment.