From: Hsia-Jun Li <Randy.Li@synaptics.com>
To: linaro-mm-sig@lists.linaro.org
Cc: sumit.semwal@linaro.org,
Benjamin Gaignard <benjamin.gaignard@collabora.com>,
Brian.Starkey@arm.com, jstultz@google.com, tjmercier@google.com,
christian.koenig@amd.com,
Linux Media Mailing List <linux-media@vger.kernel.org>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [PATCH] dma-buf/heaps: map CMA all pages for user
Date: Mon, 21 Aug 2023 17:55:51 +0800 [thread overview]
Message-ID: <242cf022-503d-553a-8b78-f0abdb58d374@synaptics.com> (raw)
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
reply other threads:[~2023-08-21 9:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=242cf022-503d-553a-8b78-f0abdb58d374@synaptics.com \
--to=randy.li@synaptics.com \
--cc=Brian.Starkey@arm.com \
--cc=benjamin.gaignard@collabora.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jstultz@google.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=sumit.semwal@linaro.org \
--cc=tjmercier@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®