Skip to content

Commit 9061b6f

Browse files
etienne-lmsfourmone
authored andcommitted
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]> [etienne: picked commit from linaro-swg/linux#72] Signed-off-by: Etienne Carriere <[email protected]> Change-Id: I4ec1ef1f3a44b9000ef26717a52853cecd3fcaa3
1 parent 2aa2627 commit 9061b6f

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
@@ -431,6 +431,17 @@ struct tee_shm *tee_shm_get_from_id(struct tee_context *ctx, int id)
431431
}
432432
EXPORT_SYMBOL_GPL(tee_shm_get_from_id);
433433

434+
/**
435+
* tee_shm_get() - Increase reference count on a shared memory handle
436+
* @shm: Shared memory handle
437+
*/
438+
void tee_shm_get(struct tee_shm *shm)
439+
{
440+
if (shm->flags & TEE_SHM_DMA_BUF)
441+
get_dma_buf(shm->dmabuf);
442+
}
443+
EXPORT_SYMBOL_GPL(tee_shm_get);
444+
434445
/**
435446
* tee_shm_put() - Decrease reference count on a shared memory handle
436447
* @shm: Shared memory handle

include/linux/tee_drv.h

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

366+
/**
367+
* tee_shm_get() - Increase reference count on a shared memory handle
368+
* @shm: Shared memory handle
369+
*/
370+
void tee_shm_get(struct tee_shm *shm);
371+
366372
/**
367373
* tee_shm_put() - Decrease reference count on a shared memory handle
368374
* @shm: Shared memory handle

0 commit comments

Comments
 (0)