summaryrefslogtreecommitdiff
path: root/drivers/tee/tee_shm.c
diff options
context:
space:
mode:
authorJens Wiklander <jens.wiklander@linaro.org>2022-02-04 12:33:52 +0300
committerJens Wiklander <jens.wiklander@linaro.org>2022-02-16 09:49:41 +0300
commit71cc47d4cc1f7a333584e0f2f7c863c71a6d3ced (patch)
tree8755e5e5e8e856aff8671a7473016f7fc5e44526 /drivers/tee/tee_shm.c
parentf41b6be1ebdae452819551ed35a46e6fd32bf467 (diff)
downloadlinux-71cc47d4cc1f7a333584e0f2f7c863c71a6d3ced.tar.xz
tee: add tee_shm_alloc_user_buf()
Adds a new function tee_shm_alloc_user_buf() for user mode allocations, replacing passing the flags TEE_SHM_MAPPED | TEE_SHM_DMA_BUF to tee_shm_alloc(). Reviewed-by: Sumit Garg <sumit.garg@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'drivers/tee/tee_shm.c')
-rw-r--r--drivers/tee/tee_shm.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c
index 499fccba3d74..7e7e762fc1de 100644
--- a/drivers/tee/tee_shm.c
+++ b/drivers/tee/tee_shm.c
@@ -128,6 +128,23 @@ err_dev_put:
EXPORT_SYMBOL_GPL(tee_shm_alloc);
/**
+ * tee_shm_alloc_user_buf() - Allocate shared memory for user space
+ * @ctx: Context that allocates the shared memory
+ * @size: Requested size of shared memory
+ *
+ * Memory allocated as user space shared memory is automatically freed when
+ * the TEE file pointer is closed. The primary usage of this function is
+ * when the TEE driver doesn't support registering ordinary user space
+ * memory.
+ *
+ * @returns a pointer to 'struct tee_shm'
+ */
+struct tee_shm *tee_shm_alloc_user_buf(struct tee_context *ctx, size_t size)
+{
+ return tee_shm_alloc(ctx, size, TEE_SHM_MAPPED | TEE_SHM_DMA_BUF);
+}
+
+/**
* tee_shm_alloc_kernel_buf() - Allocate shared memory for kernel buffer
* @ctx: Context that allocates the shared memory
* @size: Requested size of shared memory