Skip to content

Commit be70804

Browse files
author
Hernan Gatta
committed
tee: add helper method to increase the refcount on an SHM
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]>
1 parent ff602f2 commit be70804

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

drivers/tee/tee_shm.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,17 @@ struct tee_shm *tee_shm_get_from_id(struct tee_context *ctx, int id)
571571
}
572572
EXPORT_SYMBOL_GPL(tee_shm_get_from_id);
573573

574+
/**
575+
* tee_shm_get() - Increase reference count on a shared memory handle
576+
* @shm: Shared memory handle
577+
*/
578+
void tee_shm_get(struct tee_shm *shm)
579+
{
580+
if (shm->flags & TEE_SHM_DMA_BUF)
581+
get_dma_buf(shm->dmabuf);
582+
}
583+
EXPORT_SYMBOL_GPL(tee_shm_get);
584+
574585
/**
575586
* tee_shm_put() - Decrease reference count on a shared memory handle
576587
* @shm: Shared memory handle

include/linux/tee_drv.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,12 @@ static inline bool tee_shm_is_registered(struct tee_shm *shm)
372372
*/
373373
void tee_shm_free(struct tee_shm *shm);
374374

375+
/**
376+
* tee_shm_get() - Increase reference count on a shared memory handle
377+
* @shm: Shared memory handle
378+
*/
379+
void tee_shm_get(struct tee_shm *shm);
380+
375381
/**
376382
* tee_shm_put() - Decrease reference count on a shared memory handle
377383
* @shm: Shared memory handle

0 commit comments

Comments
 (0)