linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tee: add FOLL_LONGTERM for CMA case when alloc shm
@ 2023-05-17  3:18 Xiaoming Ding
  2023-05-17  7:34 ` Christoph Hellwig
  0 siblings, 1 reply; 16+ messages in thread
From: Xiaoming Ding @ 2023-05-17  3:18 UTC (permalink / raw)
  To: Jens Wiklander, Sumit Garg, Matthias Brugger,
	AngeloGioacchino Del Regno, op-tee, linux-kernel,
	linux-arm-kernel, linux-mediatek
  Cc: fei.xu, srv_heupstream, Xiaoming Ding

FOLL_LONGTERM will avoid share memory alloc from CMA region,
which may be used in secure playback case.
if part of CMA region taken by share memory for long term usage,
CMA will failed to get whole buffer back.

Signed-off-by: Xiaoming Ding <xiaoming.ding@mediatek.com>
---
 drivers/tee/tee_shm.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c
index 673cf0359494..ddd3947e2229 100644
--- a/drivers/tee/tee_shm.c
+++ b/drivers/tee/tee_shm.c
@@ -223,6 +223,7 @@ register_shm_helper(struct tee_context *ctx, unsigned long addr,
 	size_t num_pages;
 	void *ret;
 	int rc;
+	u32 page_flag = FOLL_WRITE;
 
 	if (!tee_device_get(teedev))
 		return ERR_PTR(-EINVAL);
@@ -255,9 +256,11 @@ register_shm_helper(struct tee_context *ctx, unsigned long addr,
 		ret = ERR_PTR(-ENOMEM);
 		goto err_free_shm;
 	}
-
+#if IS_ENABLED(CONFIG_CMA)
+	page_flag |= FOLL_LONGTERM;
+#endif
 	if (flags & TEE_SHM_USER_MAPPED)
-		rc = pin_user_pages_fast(start, num_pages, FOLL_WRITE,
+		rc = pin_user_pages_fast(start, num_pages, page_flag,
 					 shm->pages);
 	else
 		rc = shm_get_kernel_pages(start, num_pages, shm->pages);
-- 
2.18.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-06-13  8:49 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-17  3:18 [PATCH] tee: add FOLL_LONGTERM for CMA case when alloc shm Xiaoming Ding
2023-05-17  7:34 ` Christoph Hellwig
2023-05-17  7:52   ` Sumit Garg
2023-05-17  8:08     ` Christoph Hellwig
2023-05-17  9:26       ` Sumit Garg
2023-05-17  9:36         ` Christoph Hellwig
2023-05-17 10:19           ` Sumit Garg
2023-05-17 18:23             ` David Hildenbrand
2023-05-18  4:20               ` FOLL_LONGTERM vs FOLL_EPHEMERAL " Christoph Hellwig
2023-05-18  6:08                 ` Sumit Garg
2023-05-18 13:56                   ` David Hildenbrand
2023-05-23  1:54                     ` John Hubbard
2023-05-23  7:25                       ` Lorenzo Stoakes
     [not found]                         ` <acc5f89dee4426e8c8953eabc65e932f22dde169.camel@mediatek.com>
2023-06-13  8:48                           ` Sumit Garg
     [not found]             ` <781d993204fbbdf30a6ca495b59b3b0aa7a2e496.camel@mediatek.com>
2023-05-19 10:01               ` David Hildenbrand
2023-05-19 11:03                 ` Sumit Garg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).