diff mbox series

[4.19,36/54] tee: add tee_shm_alloc_kernel_buf()

Message ID 20210810172945.369365872@linuxfoundation.org
State Superseded
Headers show
Series None | expand

Commit Message

Greg KH Aug. 10, 2021, 5:30 p.m. UTC
From: Jens Wiklander <jens.wiklander@linaro.org>


commit dc7019b7d0e188d4093b34bd0747ed0d668c63bf upstream.

Adds a new function tee_shm_alloc_kernel_buf() to allocate shared memory
from a kernel driver. This function can later be made more lightweight
by unnecessary dma-buf export.

Cc: stable@vger.kernel.org
Reviewed-by: Tyler Hicks <tyhicks@linux.microsoft.com>

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/tee/tee_shm.c   |   18 ++++++++++++++++++
 include/linux/tee_drv.h |    1 +
 2 files changed, 19 insertions(+)

Comments

Pavel Machek Aug. 11, 2021, 7:24 a.m. UTC | #1
Hi!

> commit dc7019b7d0e188d4093b34bd0747ed0d668c63bf upstream.

> 

> Adds a new function tee_shm_alloc_kernel_buf() to allocate shared memory

> from a kernel driver. This function can later be made more lightweight

> by unnecessary dma-buf export.


5.10 contains follow-up patches actually using the export, but 4.19
does not. I believe it should be dropped from 4.19.

Best regards,
								Pavel
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Tyler Hicks Aug. 11, 2021, 1:34 p.m. UTC | #2
On 2021-08-11 09:24:34, Pavel Machek wrote:
> Hi!

> 

> > commit dc7019b7d0e188d4093b34bd0747ed0d668c63bf upstream.

> > 

> > Adds a new function tee_shm_alloc_kernel_buf() to allocate shared memory

> > from a kernel driver. This function can later be made more lightweight

> > by unnecessary dma-buf export.

> 

> 5.10 contains follow-up patches actually using the export, but 4.19

> does not. I believe it should be dropped from 4.19.


That's correct. Those follow-up patches that made use of this function
were only needed back to 5.4.

Tyler

> 

> Best regards,

> 								Pavel

> -- 

> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk

> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Greg KH Aug. 12, 2021, 10:56 a.m. UTC | #3
On Wed, Aug 11, 2021 at 08:34:27AM -0500, Tyler Hicks wrote:
> On 2021-08-11 09:24:34, Pavel Machek wrote:

> > Hi!

> > 

> > > commit dc7019b7d0e188d4093b34bd0747ed0d668c63bf upstream.

> > > 

> > > Adds a new function tee_shm_alloc_kernel_buf() to allocate shared memory

> > > from a kernel driver. This function can later be made more lightweight

> > > by unnecessary dma-buf export.

> > 

> > 5.10 contains follow-up patches actually using the export, but 4.19

> > does not. I believe it should be dropped from 4.19.

> 

> That's correct. Those follow-up patches that made use of this function

> were only needed back to 5.4.


Now dropped, thanks.

greg k-h
diff mbox series

Patch

--- a/drivers/tee/tee_shm.c
+++ b/drivers/tee/tee_shm.c
@@ -228,6 +228,24 @@  struct tee_shm *tee_shm_priv_alloc(struc
 }
 EXPORT_SYMBOL_GPL(tee_shm_priv_alloc);
 
+/**
+ * tee_shm_alloc_kernel_buf() - Allocate shared memory for kernel buffer
+ * @ctx:	Context that allocates the shared memory
+ * @size:	Requested size of shared memory
+ *
+ * The returned memory registered in secure world and is suitable to be
+ * passed as a memory buffer in parameter argument to
+ * tee_client_invoke_func(). The memory allocated is later freed with a
+ * call to tee_shm_free().
+ *
+ * @returns a pointer to 'struct tee_shm'
+ */
+struct tee_shm *tee_shm_alloc_kernel_buf(struct tee_context *ctx, size_t size)
+{
+	return tee_shm_alloc(ctx, size, TEE_SHM_MAPPED | TEE_SHM_DMA_BUF);
+}
+EXPORT_SYMBOL_GPL(tee_shm_alloc_kernel_buf);
+
 struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr,
 				 size_t length, u32 flags)
 {
--- a/include/linux/tee_drv.h
+++ b/include/linux/tee_drv.h
@@ -317,6 +317,7 @@  void *tee_get_drvdata(struct tee_device
  * @returns a pointer to 'struct tee_shm'
  */
 struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags);
+struct tee_shm *tee_shm_alloc_kernel_buf(struct tee_context *ctx, size_t size);
 
 /**
  * tee_shm_priv_alloc() - Allocate shared memory privately