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]>
  • Loading branch information
HernanGatta committed Apr 5, 2021
1 parent ff602f2 commit be70804
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 @@ -571,6 +571,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 @@ -372,6 +372,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 be70804

Please sign in to comment.