Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
dma-buf.c File Reference
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/dma-buf.h>
#include <linux/anon_inodes.h>
#include <linux/export.h>

Go to the source code of this file.

Functions

struct dma_bufdma_buf_export (void *priv, const struct dma_buf_ops *ops, size_t size, int flags)
 
 EXPORT_SYMBOL_GPL (dma_buf_export)
 
int dma_buf_fd (struct dma_buf *dmabuf, int flags)
 
 EXPORT_SYMBOL_GPL (dma_buf_fd)
 
struct dma_bufdma_buf_get (int fd)
 
 EXPORT_SYMBOL_GPL (dma_buf_get)
 
void dma_buf_put (struct dma_buf *dmabuf)
 
 EXPORT_SYMBOL_GPL (dma_buf_put)
 
struct dma_buf_attachmentdma_buf_attach (struct dma_buf *dmabuf, struct device *dev)
 
 EXPORT_SYMBOL_GPL (dma_buf_attach)
 
void dma_buf_detach (struct dma_buf *dmabuf, struct dma_buf_attachment *attach)
 
 EXPORT_SYMBOL_GPL (dma_buf_detach)
 
struct sg_tabledma_buf_map_attachment (struct dma_buf_attachment *attach, enum dma_data_direction direction)
 
 EXPORT_SYMBOL_GPL (dma_buf_map_attachment)
 
void dma_buf_unmap_attachment (struct dma_buf_attachment *attach, struct sg_table *sg_table, enum dma_data_direction direction)
 
 EXPORT_SYMBOL_GPL (dma_buf_unmap_attachment)
 
int dma_buf_begin_cpu_access (struct dma_buf *dmabuf, size_t start, size_t len, enum dma_data_direction direction)
 
 EXPORT_SYMBOL_GPL (dma_buf_begin_cpu_access)
 
void dma_buf_end_cpu_access (struct dma_buf *dmabuf, size_t start, size_t len, enum dma_data_direction direction)
 
 EXPORT_SYMBOL_GPL (dma_buf_end_cpu_access)
 
voiddma_buf_kmap_atomic (struct dma_buf *dmabuf, unsigned long page_num)
 
 EXPORT_SYMBOL_GPL (dma_buf_kmap_atomic)
 
void dma_buf_kunmap_atomic (struct dma_buf *dmabuf, unsigned long page_num, void *vaddr)
 
 EXPORT_SYMBOL_GPL (dma_buf_kunmap_atomic)
 
voiddma_buf_kmap (struct dma_buf *dmabuf, unsigned long page_num)
 
 EXPORT_SYMBOL_GPL (dma_buf_kmap)
 
void dma_buf_kunmap (struct dma_buf *dmabuf, unsigned long page_num, void *vaddr)
 
 EXPORT_SYMBOL_GPL (dma_buf_kunmap)
 
int dma_buf_mmap (struct dma_buf *dmabuf, struct vm_area_struct *vma, unsigned long pgoff)
 
 EXPORT_SYMBOL_GPL (dma_buf_mmap)
 
voiddma_buf_vmap (struct dma_buf *dmabuf)
 
 EXPORT_SYMBOL_GPL (dma_buf_vmap)
 
void dma_buf_vunmap (struct dma_buf *dmabuf, void *vaddr)
 
 EXPORT_SYMBOL_GPL (dma_buf_vunmap)
 

Function Documentation

struct dma_buf_attachment* dma_buf_attach ( struct dma_buf dmabuf,
struct device dev 
)
read

dma_buf_attach - Add the device to dma_buf's attachments list; optionally, calls attach() of dma_buf_ops to allow device-specific attach functionality : [in] buffer to attach device to. : [in] device to be attached.

Returns struct dma_buf_attachment * for this attachment; may return negative error codes.

Definition at line 204 of file dma-buf.c.

int dma_buf_begin_cpu_access ( struct dma_buf dmabuf,
size_t  start,
size_t  len,
enum dma_data_direction  direction 
)

dma_buf_begin_cpu_access - Must be called before accessing a dma_buf from the 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. : [in] buffer to prepare cpu access for. : [in] start of range for cpu access. : [in] length of range for cpu access. : [in] length of range for cpu access.

Can return negative error values, returns 0 on success.

Definition at line 322 of file dma-buf.c.

void dma_buf_detach ( struct dma_buf dmabuf,
struct dma_buf_attachment attach 
)

dma_buf_detach - Remove the given attachment from dmabuf's attachments list; optionally calls detach() of dma_buf_ops for device-specific detach : [in] buffer to detach from. : [in] attachment to be detached; is free'd after this call.

Definition at line 246 of file dma-buf.c.

void dma_buf_end_cpu_access ( struct dma_buf dmabuf,
size_t  start,
size_t  len,
enum dma_data_direction  direction 
)

dma_buf_end_cpu_access - Must be called after accessing a dma_buf from the 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. : [in] buffer to complete cpu access for. : [in] start of range for cpu access. : [in] length of range for cpu access. : [in] length of range for cpu access.

This call must always succeed.

Definition at line 349 of file dma-buf.c.

struct dma_buf* dma_buf_export ( void priv,
const struct dma_buf_ops ops,
size_t  size,
int  flags 
)
read

dma_buf_export - Creates a new dma_buf, and associates an anon file with this buffer, so it can be exported. Also connect the allocator specific data and ops to the buffer.

: [in] Attach private data of allocator to this buffer : [in] Attach allocator-defined dma buf ops to the new buffer. : [in] Size of the buffer : [in] mode flags for the file.

Returns, on success, a newly created dma_buf object, which wraps the supplied private data and operations for dma_buf_ops. On either missing ops, or error in allocating struct dma_buf, will return negative error.

Definition at line 92 of file dma-buf.c.

int dma_buf_fd ( struct dma_buf dmabuf,
int  flags 
)

dma_buf_fd - returns a file descriptor for the given dma_buf : [in] pointer to dma_buf for which fd is required. : [in] flags to give to fd

On success, returns an associated 'fd'. Else, returns error.

Definition at line 135 of file dma-buf.c.

struct dma_buf* dma_buf_get ( int  fd)
read

dma_buf_get - returns the dma_buf structure related to an fd : [in] fd associated with the dma_buf to be returned

On success, returns the dma_buf structure associated with an fd; uses file's refcounting done by fget to increase refcount. returns ERR_PTR otherwise.

Definition at line 161 of file dma-buf.c.

void* dma_buf_kmap ( struct dma_buf dmabuf,
unsigned long  page_num 
)

dma_buf_kmap - Map a page of the buffer object into kernel address space. The same restrictions as for kmap and friends apply. : [in] buffer to map page from. : [in] page in PAGE_SIZE units to map.

This call must always succeed, any necessary preparations that might fail need to be done in begin_cpu_access.

Definition at line 403 of file dma-buf.c.

void* dma_buf_kmap_atomic ( struct dma_buf dmabuf,
unsigned long  page_num 
)

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. : [in] buffer to map page from. : [in] page in PAGE_SIZE units to map.

This call must always succeed, any necessary preparations that might fail need to be done in begin_cpu_access.

Definition at line 368 of file dma-buf.c.

void dma_buf_kunmap ( struct dma_buf dmabuf,
unsigned long  page_num,
void vaddr 
)

dma_buf_kunmap - Unmap a page obtained by dma_buf_kmap. : [in] buffer to unmap page from. : [in] page in PAGE_SIZE units to unmap. : [in] kernel space pointer obtained from dma_buf_kmap.

This call must always succeed.

Definition at line 419 of file dma-buf.c.

void dma_buf_kunmap_atomic ( struct dma_buf dmabuf,
unsigned long  page_num,
void vaddr 
)

dma_buf_kunmap_atomic - Unmap a page obtained by dma_buf_kmap_atomic. : [in] buffer to unmap page from. : [in] page in PAGE_SIZE units to unmap. : [in] kernel space pointer obtained from dma_buf_kmap_atomic.

This call must always succeed.

Definition at line 384 of file dma-buf.c.

struct sg_table* dma_buf_map_attachment ( struct dma_buf_attachment attach,
enum dma_data_direction  direction 
)
read

dma_buf_map_attachment - Returns the scatterlist table of the attachment; mapped into device address space. Is a wrapper for map_dma_buf() of the dma_buf_ops. : [in] attachment whose scatterlist is to be returned : [in] direction of DMA transfer

Returns sg_table containing the scatterlist to be returned; may return NULL or ERR_PTR.

Definition at line 272 of file dma-buf.c.

int dma_buf_mmap ( struct dma_buf dmabuf,
struct vm_area_struct vma,
unsigned long  pgoff 
)

dma_buf_mmap - Setup up a userspace mmap with the given vma : [in] buffer that should back the vma : [in] vma for the mmap : [in] offset in pages where this mmap should start within the dma-buf buffer.

This function adjusts the passed in vma so that it points at the file of the dma_buf operation. It alsog adjusts the starting pgoff and does bounds checking on the size of the vma. Then it calls the exporters mmap function to set up the mapping.

Can return negative error values, returns 0 on success.

Definition at line 444 of file dma-buf.c.

void dma_buf_put ( struct dma_buf dmabuf)

dma_buf_put - decreases refcount of the buffer : [in] buffer to reduce refcount of

Uses file's refcounting done implicitly by fput()

Definition at line 185 of file dma-buf.c.

void dma_buf_unmap_attachment ( struct dma_buf_attachment attach,
struct sg_table sg_table,
enum dma_data_direction  direction 
)

dma_buf_unmap_attachment - unmaps and decreases usecount of the buffer;might deallocate the scatterlist associated. Is a wrapper for unmap_dma_buf() of dma_buf_ops. : [in] attachment to unmap buffer from : [in] scatterlist info of the buffer to unmap : [in] direction of DMA transfer

Definition at line 297 of file dma-buf.c.

void* dma_buf_vmap ( struct dma_buf dmabuf)

dma_buf_vmap - Create virtual mapping for the buffer object into kernel address space. Same restrictions as for vmap and friends apply. : [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.

Definition at line 481 of file dma-buf.c.

void dma_buf_vunmap ( struct dma_buf dmabuf,
void vaddr 
)

dma_buf_vunmap - Unmap a vmap obtained by dma_buf_vmap. : [in] buffer to vunmap : [in] vmap to vunmap

Definition at line 497 of file dma-buf.c.

EXPORT_SYMBOL_GPL ( dma_buf_export  )
EXPORT_SYMBOL_GPL ( dma_buf_fd  )
EXPORT_SYMBOL_GPL ( dma_buf_get  )
EXPORT_SYMBOL_GPL ( dma_buf_put  )
EXPORT_SYMBOL_GPL ( dma_buf_attach  )
EXPORT_SYMBOL_GPL ( dma_buf_detach  )
EXPORT_SYMBOL_GPL ( dma_buf_map_attachment  )
EXPORT_SYMBOL_GPL ( dma_buf_unmap_attachment  )
EXPORT_SYMBOL_GPL ( dma_buf_begin_cpu_access  )
EXPORT_SYMBOL_GPL ( dma_buf_end_cpu_access  )
EXPORT_SYMBOL_GPL ( dma_buf_kmap_atomic  )
EXPORT_SYMBOL_GPL ( dma_buf_kunmap_atomic  )
EXPORT_SYMBOL_GPL ( dma_buf_kmap  )
EXPORT_SYMBOL_GPL ( dma_buf_kunmap  )
EXPORT_SYMBOL_GPL ( dma_buf_mmap  )
EXPORT_SYMBOL_GPL ( dma_buf_vmap  )
EXPORT_SYMBOL_GPL ( dma_buf_vunmap  )