mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dma-buf/heaps: map CMA all pages for user
@ 2023-08-21  9:55 Hsia-Jun Li
  0 siblings, 0 replies; only message in thread
From: Hsia-Jun Li @ 2023-08-21  9:55 UTC (permalink / raw)
  To: linaro-mm-sig
  Cc: sumit.semwal, Benjamin Gaignard, Brian.Starkey, jstultz,
	tjmercier, christian.koenig, Linux Media Mailing List, dri-devel,
	linux-kernel

Page fault would raise a CPU interrupt, it is not
a good idea.

Signed-off-by: Hsia-Jun(Randy) Li <randy.li@synaptics.com>
---
  drivers/dma-buf/heaps/cma_heap.c | 26 +++-----------------------
  1 file changed, 3 insertions(+), 23 deletions(-)

diff --git a/drivers/dma-buf/heaps/cma_heap.c 
b/drivers/dma-buf/heaps/cma_heap.c
index ee899f8e6721..7d0b15ad21a7 100644
--- a/drivers/dma-buf/heaps/cma_heap.c
+++ b/drivers/dma-buf/heaps/cma_heap.c
@@ -160,35 +160,15 @@ static int cma_heap_dma_buf_end_cpu_access(struct 
dma_buf *dmabuf,
  	return 0;
  }
  -static vm_fault_t cma_heap_vm_fault(struct vm_fault *vmf)
-{
-	struct vm_area_struct *vma = vmf->vma;
-	struct cma_heap_buffer *buffer = vma->vm_private_data;
-
-	if (vmf->pgoff > buffer->pagecount)
-		return VM_FAULT_SIGBUS;
-
-	vmf->page = buffer->pages[vmf->pgoff];
-	get_page(vmf->page);
-
-	return 0;
-}
-
-static const struct vm_operations_struct dma_heap_vm_ops = {
-	.fault = cma_heap_vm_fault,
-};
-
  static int cma_heap_mmap(struct dma_buf *dmabuf, struct vm_area_struct 
*vma)
  {
  	struct cma_heap_buffer *buffer = dmabuf->priv;
-
  	if ((vma->vm_flags & (VM_SHARED | VM_MAYSHARE)) == 0)
  		return -EINVAL;
  -	vma->vm_ops = &dma_heap_vm_ops;
-	vma->vm_private_data = buffer;
-
-	return 0;
+	return remap_pfn_range(vma, vma->vm_start,
+			       page_to_pfn(buffer->pages[vma->vm_pgoff]),
+			       vma->vm_end - vma->vm_start, vma->vm_page_prot);
  }
   static void *cma_heap_do_vmap(struct cma_heap_buffer *buffer)
-- 
2.17.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-21  9:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-21  9:55 [PATCH] dma-buf/heaps: map CMA all pages for user Hsia-Jun Li

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®