dma_buf_mmap(9)
π dma_buf_mmap β like, the Kernel API Manual, bestie
Okay so this is dma_buf_mmap(9) from the Kernel API Manual and it's genuinely the moment your userspace memory gets to touch a dma-buf. Sit down, this one's cute.
β¨ NAME β¨
dma_buf_mmap β Setup up a userspace mmap with the given vma π«Ά (yes, "Setup up", that's what it says, we don't edit the original text, we respect the original text)
πΈ SYNOPSIS πΈ
int dma_buf_mmap (struct dma_buf *dmabuf , struct vm_area_struct *vma ,
unsigned long pgoff );
Three args, one int back, that's the whole vibe. π
π ARGUMENTS π
dmabufβ[in]β the buffer that should back the vma. Like, the actual dma-buf that's gonna be the main character underneath your mapping. πvmaβ[in]β the vma for themmap. This is the thing getting adjusted, so heads up, it's not staying exactly how you handed it over. πpgoffβ[in]β offset in pages where thismmapshould start within the dma-buf buffer. Pages, bestie, not bytes. Don't do bytes. π
π¦ DESCRIPTION π¦
So what this function does is, like, a whole little glow-up routine on the vma you pass in:
- it adjusts the passed-in
vmaso that it points at the file of thedma_bufoperation β¨ - it also adjusts the starting
pgoffπ§ - and it does bounds checking on the size of the
vma(safety first, always) π₯
Then β and this is the slay part β it calls the exporter's mmap function to actually set up the mapping. So it's giving middle-manager energy: it does the setup and validation, then hands the real work off to whoever exported the buffer. π
It can return negative error values, and it returns 0 on success. That's the contract. Negative = something went sideways, 0 = we ate and left no crumbs. β
π SEE ALSO π
The kernel file for this is ./drivers/dma-buf/dma-buf.c β go read it, it's right there and it's iconic. Then the whole extended friend group:
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(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_vmap(9)dma_buf_vmap_unlocked(9)dma_buf_vunmap(9)dma_buf_vunmap_unlocked(9)
Fr fr, that's all of them β do not skip the list, every single one of those (9) pages is part of the lore. iykq π
And that's the whole page, bestie! π Cute little sign-off below: this one lives in ./drivers/dma-buf, it's dated October 2026, and it's from the Kernel API Manual. Mwah, go mmap something 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