]> Pileus Git - ~andy/linux/blobdiff - drivers/base/dma-buf.c
Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso...
[~andy/linux] / drivers / base / dma-buf.c
index 7cfb405b1ad5d7d5787a50ebe6f85fffd768820b..24e88fe29ec19801f627e55b7b454fbbe8268181 100644 (file)
@@ -312,7 +312,7 @@ EXPORT_SYMBOL_GPL(dma_buf_unmap_attachment);
  * cpu in the kernel context. Calls begin_cpu_access to allow exporter-specific
  * preparations. Coherency is only guaranteed in the specified range for the
  * specified access direction.
- * @dma_buf:   [in]    buffer to prepare cpu access for.
+ * @dmabuf:    [in]    buffer to prepare cpu access for.
  * @start:     [in]    start of range for cpu access.
  * @len:       [in]    length of range for cpu access.
  * @direction: [in]    length of range for cpu access.
@@ -339,7 +339,7 @@ EXPORT_SYMBOL_GPL(dma_buf_begin_cpu_access);
  * cpu in the kernel context. Calls end_cpu_access to allow exporter-specific
  * actions. Coherency is only guaranteed in the specified range for the
  * specified access direction.
- * @dma_buf:   [in]    buffer to complete cpu access for.
+ * @dmabuf:    [in]    buffer to complete cpu access for.
  * @start:     [in]    start of range for cpu access.
  * @len:       [in]    length of range for cpu access.
  * @direction: [in]    length of range for cpu access.
@@ -359,7 +359,7 @@ EXPORT_SYMBOL_GPL(dma_buf_end_cpu_access);
 /**
  * dma_buf_kmap_atomic - Map a page of the buffer object into kernel address
  * space. The same restrictions as for kmap_atomic and friends apply.
- * @dma_buf:   [in]    buffer to map page from.
+ * @dmabuf:    [in]    buffer to map page from.
  * @page_num:  [in]    page in PAGE_SIZE units to map.
  *
  * This call must always succeed, any necessary preparations that might fail
@@ -375,7 +375,7 @@ EXPORT_SYMBOL_GPL(dma_buf_kmap_atomic);
 
 /**
  * dma_buf_kunmap_atomic - Unmap a page obtained by dma_buf_kmap_atomic.
- * @dma_buf:   [in]    buffer to unmap page from.
+ * @dmabuf:    [in]    buffer to unmap page from.
  * @page_num:  [in]    page in PAGE_SIZE units to unmap.
  * @vaddr:     [in]    kernel space pointer obtained from dma_buf_kmap_atomic.
  *
@@ -394,7 +394,7 @@ EXPORT_SYMBOL_GPL(dma_buf_kunmap_atomic);
 /**
  * dma_buf_kmap - Map a page of the buffer object into kernel address space. The
  * same restrictions as for kmap and friends apply.
- * @dma_buf:   [in]    buffer to map page from.
+ * @dmabuf:    [in]    buffer to map page from.
  * @page_num:  [in]    page in PAGE_SIZE units to map.
  *
  * This call must always succeed, any necessary preparations that might fail
@@ -410,7 +410,7 @@ EXPORT_SYMBOL_GPL(dma_buf_kmap);
 
 /**
  * dma_buf_kunmap - Unmap a page obtained by dma_buf_kmap.
- * @dma_buf:   [in]    buffer to unmap page from.
+ * @dmabuf:    [in]    buffer to unmap page from.
  * @page_num:  [in]    page in PAGE_SIZE units to unmap.
  * @vaddr:     [in]    kernel space pointer obtained from dma_buf_kmap.
  *
@@ -429,7 +429,7 @@ EXPORT_SYMBOL_GPL(dma_buf_kunmap);
 
 /**
  * dma_buf_mmap - Setup up a userspace mmap with the given vma
- * @dma_buf:   [in]    buffer that should back the vma
+ * @dmabuf:    [in]    buffer that should back the vma
  * @vma:       [in]    vma for the mmap
  * @pgoff:     [in]    offset in pages where this mmap should start within the
  *                     dma-buf buffer.
@@ -468,3 +468,38 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
        return dmabuf->ops->mmap(dmabuf, vma);
 }
 EXPORT_SYMBOL_GPL(dma_buf_mmap);
+
+/**
+ * dma_buf_vmap - Create virtual mapping for the buffer object into kernel
+ * address space. Same restrictions as for vmap and friends apply.
+ * @dmabuf:    [in]    buffer to vmap
+ *
+ * This call may fail due to lack of virtual mapping address space.
+ * These calls are optional in drivers. The intended use for them
+ * is for mapping objects linear in kernel space for high use objects.
+ * Please attempt to use kmap/kunmap before thinking about these interfaces.
+ */
+void *dma_buf_vmap(struct dma_buf *dmabuf)
+{
+       if (WARN_ON(!dmabuf))
+               return NULL;
+
+       if (dmabuf->ops->vmap)
+               return dmabuf->ops->vmap(dmabuf);
+       return NULL;
+}
+EXPORT_SYMBOL_GPL(dma_buf_vmap);
+
+/**
+ * dma_buf_vunmap - Unmap a vmap obtained by dma_buf_vmap.
+ * @dmabuf:    [in]    buffer to vunmap
+ */
+void dma_buf_vunmap(struct dma_buf *dmabuf, void *vaddr)
+{
+       if (WARN_ON(!dmabuf))
+               return;
+
+       if (dmabuf->ops->vunmap)
+               dmabuf->ops->vunmap(dmabuf, vaddr);
+}
+EXPORT_SYMBOL_GPL(dma_buf_vunmap);