dmam_alloc_attrs(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… dmam_alloc_attrs(9) β€” like, the managed version, bestie

okay so real talk, this is a page from the Kernel API Manual (yes, the kernel has a manual, she's iconic) and it's about one function: dmam_alloc_attrs. Buckle up πŸŽ€


✨ NAME ✨

dmam_alloc_attrs β€” it's the managed dma_alloc_attrs(), fr fr. That's the whole vibe: same energy, but with cleanup handled for you 🫢


🌸 SYNOPSIS 🌸

void * dmam_alloc_attrs (struct device *dev , size_t size , dma_addr_t
*dma_handle , gfp_t gfp , unsigned long attrs );

like, five things in, one void * out. classic.


πŸ¦‹ ARGUMENTS πŸ¦‹

  • dev β€” the device you're allocating that non_coherent memory for πŸ‘‘
  • size β€” how big the allocation is, obviously πŸ’…
  • dma_handle β€” an out argument, so it hands you back the allocated DMA handle ✨
  • gfp β€” the allocation flags, your standard gfp situation 🌈
  • attrs β€” flags living in the DMA_ATTR_* namespace, iykyk 🧚

πŸ’– DESCRIPTION πŸ’–

Managed dma_alloc_attrs. And the "managed" part is literally the whole point, bestie β€” memory you allocate with this function gets automatically released on driver detach. no cap. you don't have to remember to free it, the kernel's got you 😭🫢


⭐ RETURN ⭐

  • success β†’ a pointer to the allocated memory, slay πŸ’…
  • failure β†’ NULL. that's it. that's the whole vibe check πŸ’€

πŸ”₯ SEE ALSO πŸ”₯

Kernel file ./kernel/dma/mapping.c, plus the whole friend group:


go read mapping.c if you wanna see how the sausage gets made, it's lowkey fascinating πŸ“

and that's the page!! mwah πŸ’‹ this one's from ./kernel/dma, October 2026 edition β€” go off, kernel docs, you ate πŸŒŸπŸ‘‘

πŸ“¦ where this page comes from