alloc_dma_pages(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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 above phys_limit. yeah, it got too high, and yes, that's exactly what phys_limit was there to protect you from πŸ™ˆ
ngl, memorize the return values fr fr β€” NULL means the allocation failed, but ERR_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:


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