dma_buf_map_attachment(9)
π dma_buf_map_attachment β the Kernel API Manual page, bestie edition
okay so this is dma_buf_map_attachment(9) from the Kernel API Manual and it's lowkey one of the most important little functions in the dma-buf world, so likeβ¦ pay attention bestie π«Ά
β¨ NAME β¨
dma_buf_map_attachment β returns the scatterlist table of the attachment, mapped into device address space. it's literally just a wrapper for map_dma_buf() of the dma_buf_ops. that's it. that's the whole vibe. π¦
πΈ SYNOPSIS πΈ
struct sg_table * dma_buf_map_attachment (struct dma_buf_attachment
*attach , enum dma_data_direction direction );
π ARGUMENTS π
attach[in]β the attachment whose scatterlist we're returning, bestie. this is the main character here πdirection[in]β the direction of the DMA transfer. yes it matters, no you can't skip it π
π DESCRIPTION π
so what does it actually do? it returns an sg_table containing the scatterlist to be returned β and if something goes wrong it returns ERR_PTR on error. also!! it may return -EINTR if it gets interrupted by a signal. rude but true π
on success, the DMA addresses and lengths in the returned scatterlist are PAGE_SIZE aligned. slay. β¨
every mapping must be unmapped by using dma_buf_unmap_attachment. no cap, this is not optional. and here's the tea: the underlying backing storage is pinned for as long as a mapping exists, so users/importers should not hold onto a mapping for undue amounts of time. like, don't be clingy with your mappings fr fr π
Important: dynamic importers must wait for the exclusive fence of the struct dma_resv attached to the DMA-BUF first. this is the big one, don't skip it π
π¦ SEE ALSO π¦
- Kernel file
./drivers/dma-buf/dma-buf.c 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)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_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)
and that's the whole page!! this icon lives in ./drivers/dma-buf and this particular rendering is dated October 2026 in the Kernel API Manual β go read the rest of the dma-buf girlies, they all ate π
π₯β
π¦ 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