dma_iova_try_alloc(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ dma_iova_try_alloc(9) ✨

okay so bestie, welcome to the dma_iova_try_alloc page from the Kernel API Manual β€” yes that's the manual name, and yes we're covering it, because this little function is literally the vibes check for whether your device can do the whole IOVA-based DMA thing or whether you gotta slum it with the regular DMA API. πŸŽ€


🌸 NAME 🌸

dma_iova_try_alloc β€” bestie's honest attempt at allocating an IOVA space πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

bool dma_iova_try_alloc (struct device *dev , struct dma_iova_state
*state , phys_addr_t phys , size_t size );

like, that's the whole signature, no cap. returns a bool and everything πŸ”₯


🌈 ARGUMENTS 🌈

  • dev β€” the device you're allocating the IOVA space for. it's the main character here πŸ‘‘
  • state β€” the IOVA state. yes, it's just called state. slay 🫢
  • phys β€” a physical address. hold that thought, there's a note about it below πŸ‘€
  • size β€” the IOVA size. how much space we're claiming, periodt ✨

πŸ’– DESCRIPTION πŸ’–

so what this does is: it checks if dev actually supports the IOVA-based DMA API, and if it does β€” icon behaviour β€” it allocates IOVA space for the given base address and size. that's it, that's the function 🧚


⭐ NOTE ⭐

heads up bestie: phys is only used to calculate the IOVA alignment. so if your callers always do PAGE_SIZE aligned transfers, you can safely pass 0 here. no stress πŸ’œ

and the return value, because this matters: it returns true if the IOVA-based DMA API can be used and IOVA space has been allocated β€” or false if you should use the regular DMA API instead. basically a glow-up vs. staying home situation 😭


πŸ“ SEE ALSO πŸ“

kernel file ./drivers/iommu/dma-iommu.c, plus the whole friend group:


okay that's the whole page, ily, go allocate something πŸ’…βœ¨

source: ./drivers/iommu Β· version/date: October 2026 Β· that's the sign-off bestie, mwah πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from