IMPLICIT FENCE POLLING(9)
π implicit fence polling π
okay so bestie, welcome to your Kernel API Manual era β¨ β this is the implicit fence polling page, and it's lowkey iconic for anyone doing cross-device buffer sync. no cap. periodt.
To support cross-device and cross-driver synchronization of buffer access, implicit fences (represented internally in the kernel with struct dma_fence) can be attached to a dma_buf. The glue for that and a few related things is provided in the dma_resv structure. she's the main character of this whole setup, fr fr.
Userspace can query the state of these implicitly tracked fences using poll and related system calls:
- Checking for
EPOLLIN, i.e. read access, can be used to query the state of the most recent write or exclusive fence. - Checking for
EPOLLOUT, i.e. write access, can be used to query the state of all attached fences, shared and exclusive ones.
heads up, bestie: this only signals the completion of the respective fences, i.e. the DMA transfers are complete. Cache flushing and any other necessary preparations before CPU access can begin still need to happen. do not skip that part, i'm begging π
As an alternative to poll, the set of fences on a DMA buffer can be exported as a sync_file using dma_buf_sync_file_export. cute, right? π
π SEE ALSO π
Kernel file ./drivers/dma-buf/dma-buf.c β and the whole bestie squad: dma_buf_iter_begin(9), dma_buf_iter_next(9), dma_buf_set_name(9), dma buf device access(9), dma_buf_export(9), dma_buf_fd(9), dma_buf_fd_install(9), dma_buf_get(9), dma_buf_put(9), locking convention(9), dma_buf_dynamic_attach(9), dma_buf_attach(9), dma_buf_detach(9), dma_buf_pin(9), dma_buf_unpin(9), dma_buf_map_attachment(9), dma_buf_map_attachment_unlocked(9), dma_buf_unmap_attachment(9), dma_buf_unmap_attachment_unlocked(9), dma_buf_attach_revocable(9), dma_buf_invalidate_mappings(9), cpu access(9), dma_buf_begin_cpu_access(9), dma_buf_end_cpu_access(9), dma_buf_mmap(9), dma_buf_vmap(9), dma_buf_vmap_unlocked(9), dma_buf_vunmap(9), dma_buf_vunmap_unlocked(9). iykyk π
catch u in implicit fence polling(9), brought to u by ./drivers/dma-buf, October 2026 edition π
π«Ά
π¦ 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