diff mbox series

dma-buf/heaps: map CMA all pages for user

Message ID 242cf022-503d-553a-8b78-f0abdb58d374@synaptics.com
State New
Headers show
Series dma-buf/heaps: map CMA all pages for user | expand

Commit Message

Hsia-Jun Li Aug. 21, 2023, 9:55 a.m. UTC
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(-)

2.17.1
diff mbox series

Patch

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)
--