LOCKING CONVENTION(9)
π
locking convention(9) π
okay so bestie, this is locking convention(9) from the Kernel API Manual, and it's basically the group-chat rules for dma-buf locking. β¨ The whole reason this exists? Deadlock situations between dma-buf exports and importers are a vibe killer, so all dma-buf API users must follow the common dma-buf locking convention. No cap. π«Ά
π§ Convention for importers π§
- Importers must hold the dma-buf reservation lock when calling these functions:
dma_buf_pindma_buf_unpindma_buf_map_attachmentdma_buf_unmap_attachmentdma_buf_vmapdma_buf_vunmap
- Importers must not hold the dma-buf reservation lock when calling these functions:
dma_buf_attachdma_buf_dynamic_attachdma_buf_detachdma_buf_exportdma_buf_fddma_buf_getdma_buf_putdma_buf_mmapdma_buf_begin_cpu_accessdma_buf_end_cpu_accessdma_buf_map_attachment_unlockeddma_buf_unmap_attachment_unlockeddma_buf_vmap_unlockeddma_buf_vunmap_unlocked
π Convention for exporters π
- These
dma_buf_opscallbacks are invoked with unlocked dma-buf reservation and exporter can take the lock:dma_buf_ops.attachdma_buf_ops.detachdma_buf_ops.releasedma_buf_ops.begin_cpu_accessdma_buf_ops.end_cpu_accessdma_buf_ops.mmap
- These
dma_buf_opscallbacks are invoked with locked dma-buf reservation and exporter can't take the lock:dma_buf_ops.pindma_buf_ops.unpindma_buf_ops.map_dma_bufdma_buf_ops.unmap_dma_bufdma_buf_ops.vmapdma_buf_ops.vunmap
- Exporters must hold the dma-buf reservation lock when calling these functions:
dma_buf_invalidate_mappings
π SEE ALSO π
Kernel file ./drivers/dma-buf/dma-buf.c plus these iconic references: dma_buf_iter_begin(9), dma_buf_iter_next(9), implicit fence polling(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), 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). π
π that's the whole page, bestie! source/version: ./drivers/dma-buf Β· date: October 2026 Β· go forth and lock responsibly π
π¦ 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