dmam_alloc_attrs(9)
π 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 standardgfpsituation πattrsβ flags living in theDMA_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:
dmam_free_coherent(9)dma_map_sg_attrs(9)dma_map_sgtable(9)dma_need_unmap(9)dma_can_mmap(9)dma_mmap_attrs(9)dma_addressing_limited(9)
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
- 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