mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC] dma-buf: system_heap: add PTE_CONT for larger contiguous
@ 2025-12-08  9:41 gao xu
  2025-12-08  9:52 ` Barry Song
  0 siblings, 1 reply; 5+ messages in thread
From: gao xu @ 2025-12-08  9:41 UTC (permalink / raw)
  To: sumit.semwal
  Cc: Benjamin Gaignard, Brian Starkey, John Stultz,
	"T.J. Mercier", "Christian König",
	linux-media, dri-devel, linaro-mm-sig, linux-kernel, Barry Song,
	surenb, zhouxiaolong

commit 04c7adb5871a ("dma-buf: system_heap: use larger contiguous mappings
instead of per-page mmap") facilitates the use of PTE_CONT. The system_heap
allocates pages of order 4 and 8 that meet the alignment requirements for
PTE_CONT. enabling PTE_CONT for larger contiguous mappings.

After applying this patch, TLB misses are reduced by approximately 5% when
opening the camera on Android systems.

Signed-off-by: gao xu <gaoxu2@honor.com>
---
 drivers/dma-buf/heaps/system_heap.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c
index 4c782fe33..103b06f89 100644
--- a/drivers/dma-buf/heaps/system_heap.c
+++ b/drivers/dma-buf/heaps/system_heap.c
@@ -202,12 +202,16 @@ static int system_heap_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
 		unsigned long n = (sg->length >> PAGE_SHIFT) - pgoff;
 		struct page *page = sg_page(sg) + pgoff;
 		unsigned long size = n << PAGE_SHIFT;
+		pgprot_t prot = vma->vm_page_prot;
 
 		if (addr + size > vma->vm_end)
 			size = vma->vm_end - addr;
 
+		if (((addr | size) & ~CONT_PTE_MASK) == 0)
+			prot = __pgprot(pgprot_val(prot) | PTE_CONT);
+
 		ret = remap_pfn_range(vma, addr, page_to_pfn(page),
-				size, vma->vm_page_prot);
+				size, prot);
 		if (ret)
 			return ret;
 
-- 
2.42.0

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

end of thread, other threads:[~2025-12-09 12:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-08  9:41 [RFC] dma-buf: system_heap: add PTE_CONT for larger contiguous gao xu
2025-12-08  9:52 ` Barry Song
2025-12-08 10:37   ` Ryan Roberts
2025-12-09 11:37     ` Barry Song
2025-12-09 12:24       ` Ryan Roberts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®