alloc_dma_pages(9)
β¨ alloc_dma_pages(9) β¨
okay so bestie, welcome to the alloc_dma_pages page from the Kernel API Manual β yes that's a section 9 page, kernel-internals territory, but don't panic, we got this π
πΈ NAME πΈ
alloc_dma_pages β allocate pages to be used for DMA π¦
β SYNOPSIS β
struct page * alloc_dma_pages (gfp_t gfp , size_t bytes , u64 phys_limit
, unsigned long attrs );
like, that's the whole signature, no cap. four args, one struct page * coming back at you π«Ά
π ARGUMENTS π
gfpβ the GFP flags for the allocation, i.e. the whole vibe of how we're asking the buddy allocator for memory β¨bytesβ size of the buffer, literally just how many bytes you want πphys_limitβ the maximum allowed physical address of the buffer. it's giving "boundary queen", the pages have to live under this address or we're not happy πattrsβ DMA attributes for the allocation π
π DESCRIPTION π
So the way this works: it allocates pages from the buddy allocator. That's step one, main character energy π
And if that's successful, it makes the allocated pages decrypted so that they can be used for DMA. yes bestie, decrypted, that's the whole point β encrypted pages would not slay here, they'd be useless for DMA π
π₯ RETURN π₯
- Decrypted pages β the happy path, we ate π
NULLβ on allocation failure, sad but honest πERR_PTR(-EAGAIN)β if the allocated physical address was abovephys_limit. yeah, it got too high, and yes, that's exactly whatphys_limitwas there to protect you from π
ngl, memorize the return values fr fr βNULLmeans the allocation failed, butERR_PTR(-EAGAIN)means the allocation worked and then the address was out of bounds, so the error tells you something completely different. don't conflate them babes π
π¦ SEE ALSO π¦
the whole ./kernel/dma/swiotlb.c friend group, and honestly? iconic lineup:
struct io_tlb_slot(9)struct io_tlb_area(9)swiotlb_adjust_nareas(9)limit_nareas(9)add_mem_pool(9)swiotlb_alloc_tlb(9)swiotlb_free_tlb(9)swiotlb_alloc_pool(9)swiotlb_dyn_alloc(9)__swiotlb_find_pool(9)swiotlb_del_pool(9)swiotlb_dev_init(9)swiotlb_align_offset(9)swiotlb_search_pool_area(9)swiotlb_search_area(9)swiotlb_find_slots(9)mem_pool_used(9)mem_used(9)swiotlb_tbl_map_single(9)swiotlb_del_transient(9)is_swiotlb_allocated(9)default_swiotlb_base(9)default_swiotlb_limit(9)
and that's the page, bestie!! π§ sign-off time: this one lives in ./kernel/dma and it's dated October 2026 β so when you cite it, cite it cute ππ
π¦ 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