dma_mmap_from_dev_coherent(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… dma_mmap_from_dev_coherent β€” like, the Kernel API Manual page you didn't know you needed

okay bestie, gather round, because today we're talking about dma_mmap_from_dev_coherent(9) and honestly? she's a little niche but she serves. this is the Kernel API Manual entry, so you know it's the real deal ✨


🌸 NAME 🌸

dma_mmap_from_dev_coherent β€” mmap memory from the device coherent pool 🫢

like literally, it maps memory out of the per-device coherent pool. that's the whole vibe.


✨ SYNOPSIS ✨

int dma_mmap_from_dev_coherent (struct device *dev , struct
vm_area_struct *vma , void *vaddr , size_t size , int *ret );

five arguments, one int coming back at you. slay. no cap, that's the signature, don't @ me πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

  • dev β€” the device from which the memory was allocated πŸ‘‘
  • vma β€” the vm_area for the userspace memory 🌸
  • vaddr β€” the cpu address returned by dma_alloc_from_dev_coherent ⭐
  • size β€” size of the memory buffer allocated πŸ“
  • ret β€” result from remap_pfn_range πŸŒ€

πŸ¦‹ DESCRIPTION πŸ¦‹

so what does she do. okay so: this checks whether the memory was allocated from the per-device coherent memory pool, and if so, maps that memory to the provided vma. that's it. that's the whole job. iconic behavior honestly πŸ’–

and then the return value, which is where it gets kinda main-character:

  • it returns 1 if vaddr belongs to the device coherent pool and the caller should return ret πŸ”₯
  • or 0 if they should proceed with mapping memory from generic areas 🌈

so like, 1 = "yeah babe it's ours, bail out with ret", 0 = "nope, not ours, keep it moving with the generic areas". vibe check complete ✨

fr fr read the return value carefully, bestie β€” 1 and 0 mean very different things for whoever's calling you, and getting them backwards is gonna be a whole situation 😭

πŸ’œ SEE ALSO πŸ’œ

the whole coherent-pool friend group, honestly. go read them together, iykyk πŸ’…


and that's the page!! πŸŽ‰ source is ./kernel/dma, dated October 2026 β€” bookmark it, screenshot it, send it to your group chat, whatever you gotta do. bye bestie, go map some memory responsibly πŸ«Άβœ¨πŸŽ€

πŸ“¦ where this page comes from