dma_buf_mmap(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 the mmap. 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 this mmap should 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 vma so that it points at the file of the dma_buf operation ✨
  • 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:


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