aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2012-05-20 03:03:56 -0400
committerSumit Semwal <sumit.semwal@ti.com>2012-05-25 03:05:24 -0400
commit98f86c9e4ae3205e4c85c535691a5d36426360ee (patch)
tree07a533aaf702c8b0a0f6ffb0b0ee2ae6e4fe62e3 /drivers/base
parent4c78513e457f72d5554a0f6e2eabfad7b98e4f19 (diff)
dma-buf: add vmap interface
The main requirement I have for this interface is for scanning out using the USB gpu devices. Since these devices have to read the framebuffer on updates and linearly compress it, using kmaps is a major overhead for every update. v2: fix warn issues pointed out by Sylwester Nawrocki. v3: fix compile !CONFIG_DMA_SHARED_BUFFER and add _GPL for now Signed-off-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Rob Clark <rob.clark@linaro.org> Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/dma-buf.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
index 7cfb405b1ad5..d43d80256fda 100644
--- a/drivers/base/dma-buf.c
+++ b/drivers/base/dma-buf.c
@@ -468,3 +468,37 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
468 return dmabuf->ops->mmap(dmabuf, vma); 468 return dmabuf->ops->mmap(dmabuf, vma);
469} 469}
470EXPORT_SYMBOL_GPL(dma_buf_mmap); 470EXPORT_SYMBOL_GPL(dma_buf_mmap);
471
472/**
473 * dma_buf_vmap - Create virtual mapping for the buffer object into kernel address space. Same restrictions as for vmap and friends apply.
474 * @dma_buf: [in] buffer to vmap
475 *
476 * This call may fail due to lack of virtual mapping address space.
477 * These calls are optional in drivers. The intended use for them
478 * is for mapping objects linear in kernel space for high use objects.
479 * Please attempt to use kmap/kunmap before thinking about these interfaces.
480 */
481void *dma_buf_vmap(struct dma_buf *dmabuf)
482{
483 if (WARN_ON(!dmabuf))
484 return NULL;
485
486 if (dmabuf->ops->vmap)
487 return dmabuf->ops->vmap(dmabuf);
488 return NULL;
489}
490EXPORT_SYMBOL_GPL(dma_buf_vmap);
491
492/**
493 * dma_buf_vunmap - Unmap a vmap obtained by dma_buf_vmap.
494 * @dma_buf: [in] buffer to vmap
495 */
496void dma_buf_vunmap(struct dma_buf *dmabuf, void *vaddr)
497{
498 if (WARN_ON(!dmabuf))
499 return;
500
501 if (dmabuf->ops->vunmap)
502 dmabuf->ops->vunmap(dmabuf, vaddr);
503}
504EXPORT_SYMBOL_GPL(dma_buf_vunmap);