STRUCT DMA_BUF_SYNC(9)
hiii bestie π
welcome to struct dma_buf_sync(9) from the Kernel API Manual β we're literally about to make CPU access and DMA buffers get along β¨
πΈ NAME πΈ
struct dma_buf_sync β Synchronize with CPU access. no cap, that's the whole vibe check π«Ά
β¨ SYNOPSIS β¨
struct dma_buf_sync {
__u64 flags;
};
π§© Members π§©
flagsβ the set of access flags πDMA_BUF_SYNC_STARTβ Indicates the start of a map access session. π¬DMA_BUF_SYNC_ENDβ Indicates the end of a map access session. πDMA_BUF_SYNC_READβ Indicates that the mapped DMA buffer will be read by the client via the CPU map. πDMA_BUF_SYNC_WRITEβ Indicates that the mapped DMA buffer will be written by the client via the CPU map. βοΈDMA_BUF_SYNC_RWβ An alias forDMA_BUF_SYNC_READ | DMA_BUF_SYNC_WRITE. π
π« Description π«
Okay so picture this: when a DMA buffer is accessed from the CPU via mmap, it is not always possible to guarantee coherency between the CPU-visible map and underlying memory. π To manage coherency, DMA_BUF_IOCTL_SYNC must be used to bracket any CPU access to give the kernel the chance to shuffle memory around if needed. β¨
Prior to accessing the map, the client must call DMA_BUF_IOCTL_SYNC with DMA_BUF_SYNC_START and the appropriate read/write flags. Once the access is complete, the client should call DMA_BUF_IOCTL_SYNC with DMA_BUF_SYNC_END and the same read/write flags. π«Ά
The synchronization provided via DMA_BUF_IOCTL_SYNC only provides cache coherency. It does not prevent other processes or devices from accessing the memory at the same time. β οΈ If synchronization with a GPU or other device driver is required, it is the client's responsibility to wait for buffer to be ready for reading or writing before calling this ioctl with DMA_BUF_SYNC_START. Likewise, the client must ensure that follow-up work is not submitted to GPU or other device driver until after this ioctl has been called with DMA_BUF_SYNC_END? (yes bestie, that question mark is part of the sentence energy π)
If the driver or API with which the client is interacting uses implicit synchronization, waiting for prior work to complete can be done via poll on the DMA buffer file descriptor. π¦ If the driver or API requires explicit synchronization, the client may have to wait on a sync_file or other synchronization primitive outside the scope of the DMA buffer API. π
π SEE ALSO π
- Kernel file
./include/uapi/linux/dma-buf.h struct dma_buf_export_sync_file(9)struct dma_buf_import_sync_file(9)
okay that's the page bestie π source/version: ./include/uapi/linux; date: October 2026; page: struct dma_buf_sync(9). mwah π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms