dma_mmap_attrs(9)
π dma_mmap_attrs(9) β the Kernel API Manual, bestie edition π
okay so real talk: this is a page from the Kernel API Manual, and it's literally about giving user space a peek at your DMA buffer. no cap, it's iconic.
β¨ NAME β¨
dma_mmap_attrs β map a coherent DMA allocation into user space π¦
so yeah, that's the whole vibe. coherent DMA allocation β‘οΈ user space. slay.
πΈ SYNOPSIS πΈ
int dma_mmap_attrs (struct device *dev , struct vm_area_struct *vma ,
void *cpu_addr , dma_addr_t dma_addr , size_t size , unsigned long attrs
);
not me writing out the whole signature, but likeβ¦ you need it, so here it is, character for character π
π ARGUMENTS π
okay these are the glow-ups you gotta pass in. every single one matters, bestie:
devβ a validstruct devicepointer. or, and this is the fun part,NULLfor ISA and EISA-like devices π (yes, those old iconique ones)vmaβ thevm_area_structthat describes the user mapping you're asking for. it's giving "here's what user space wants" β¨cpu_addrβ the kernel CPU-view address, and β important β it's the one returned fromdma_alloc_attrsdma_addrβ the device-view address, also returned fromdma_alloc_attrs. yes, it's a different address, no, that's not a typo πsizeβ size of the memory you originally requested indma_alloc_attrs. not a new size, the original one, k?attrsβ the attributes of the mapping properties that you requested back indma_alloc_attrs. keep them matching, iykyk π«Ά
π₯ DESCRIPTION π₯
so what does it actually do? it maps a coherent DMA buffer β one that was previously allocated by dma_alloc_attrs β into user space. that's it, that's the whole buffet π
β οΈ THE BIG ONE, DO NOT SKIP THIS: the coherent DMA buffer must not be freed by the driver until the user space mapping has been released. like, fr fr. free it early and you're in for a bad time π it's the main character rule of this whole page.
π§ SEE ALSO π§
the friend group π«Ά β these all live in the kernel file ./kernel/dma/mapping.c:
dmam_free_coherent(9)dmam_alloc_attrs(9)dma_map_sg_attrs(9)dma_map_sgtable(9)dma_need_unmap(9)dma_can_mmap(9)dma_addressing_limited(9)
β¨ that's the page!! β¨ this little beauty ships out of ./kernel/dma, and the version date on it is October 2026 β so like, mark your calendars bestie ππ go map some memory, respectfully π
π¦ 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