Jump to content

User:ScotXW/DMA BUF

From Wikipedia, the free encyclopedia
(Redirected from User:ScotXW/dma-buf)

A dma-buf is a kernel DMA buffer

DMA-BUF

[edit]

The DMA-BUF framework provides a generic method for sharing buffers between multiple devices. Device drivers that support DMABUF can export a DMA buffer to userspace as a file descriptor (known as the exporter role), import a DMA buffer from userspace using a file descriptor previously exported for a different or the same device (known as the importer role), or both. [1][2]

DMA-BUF cross-device synchronization and DMA-BUF fencing was merged into Linux kernel 3.17.[3]

A fence can be attached to a buffer which is being filled or consumed by hardware, to allow userspace to pass the buffer without waiting to another device. For example, userspace can call page_flip ioctl to display the next frame of graphics after kicking the GPU but while the GPU is still rendering. The display device sharing the buffer with the GPU would attach a callback to get notified when the GPU's rendering-complete IRQ fires, to update the scan-out address of the display, without having to wake up userspace."

  1. dma-buf operations for device dma only; The dma_buf buffer sharing API usage contains the following steps
    1. Exporter announces that it wishes to export a buffer
    2. Userspace gets the file descriptor associated with the exported buffer, and passes it around to potential buffer-users based on use case
    3. Each buffer-user 'connects' itself to the buffer
    4. When needed, buffer-user requests access to the buffer from exporter
    5. When finished with its use, the buffer-user notifies end-of-DMA to exporter
    6. when buffer-user is done using this buffer completely, it 'disconnects' itself from the buffer.
  2. Kernel cpu access to a dma-buf buffer object; Access to a dma_buf from the kernel context involves three steps:
    1. Prepare access, which invalidate any necessary caches and make the object available for cpu access.
    2. Access the object page-by-page with the dma_buf map apis
    3. Finish access, which will flush any necessary cpu caches and free reserved resources.
  3. Direct Userspace Access/mmap Support



References

[edit]
  1. ^ "DMA Buffer Sharing – An Introduction" (PDF). Linaro. 2012-02-15.
  2. ^ "/Documentation/dma-buf-sharing.txt (DMA_BUF)". kernel.org.
  3. ^ "DMA-BUF Cross-Device Synchronization Hits Linux 3.17". Phoronix.