dma_mmap_attrs(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 valid struct device pointer. or, and this is the fun part, NULL for ISA and EISA-like devices πŸ™ˆ (yes, those old iconique ones)
  • vma β€” the vm_area_struct that 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 from dma_alloc_attrs
  • dma_addr β€” the device-view address, also returned from dma_alloc_attrs. yes, it's a different address, no, that's not a typo πŸ’€
  • size β€” size of the memory you originally requested in dma_alloc_attrs. not a new size, the original one, k?
  • attrs β€” the attributes of the mapping properties that you requested back in dma_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:


✨ 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