DMA_ALLOC(9)
π DMA_ALLOC(9) β Kernel Developer's Manual π
okay so bestie, welcome to the DMA-safe memory allocator page. it's from the Kernel Developer's Manual (section 9, kernel girlies only π ), and honestly it's short but it eats. let's get into it.
β¨ NAME β¨
dma_alloc, dma_free β DMA-safe memory allocator
like, it allocates. safely. for DMA. and then it frees. that's the whole vibe. π¦
πΈ SYNOPSIS πΈ
first, the magical incantations you gotta include, no cap:
#include <sys/types.h>
#include <sys/pool.h>
and here's the actual calls:
void *
dma_alloc(size_t size, int flags);
void
dma_free(void *m, size_t size);
dma_alloc hands you back a void * (the goods π₯), and dma_free takes that pointer plus the size and yeets it back into the void. void return, so it gives you nothing back except peace of mind. periodt.
π DESCRIPTION π
so what is this thing? this allocator provides DMA-safe memory, and it's managed using the pool(9) interface. it's safe to call in most contexts (iconic behaviour honestly), and it's typically used for temporary buffers up to 65536 bytes.
heads up though: if you're using buffers many times, it may be better to consider using other DMA-safe allocators. this one's the temp-buffer girlie, not the long-term-relationship girlie. π
interrupt protection is set to IPL_VM using pool_init(9). that's just how she's configured, iykyk.
now the flags argument: it's a selection of pool_get(9) flag arguments. so like, go read that page if you need the deets, because the flags come from there. π«Ά
and here's the rule that will absolutely bite you if you forget it: the same size argument must be passed to both dma_alloc() and the subsequent dma_free(). same number, both times. no improvising. and allocations over 65536 will fail. like, literally fail. not "work with a warning", not "try your best" β fail. π
π SEE ALSO π
the friend group, in alphabetical order because we're classy:
go say hi, they all know each other.
β HISTORY β
the dma_alloc interface first appeared in OpenBSD 4.8. she's been serving since 2010-ish energy and she has not lost the plot. π
k that's the page!! this was the DMA_ALLOC(9) manpage from the Debian crew, dated March 31, 2022 β mwah, love that for us, tysm for reading bestie ππ§π
π¦ where this page comes from
- nixpkgs unstable: cvs-export
- Copyright (c) 2011 Theo de Raadt
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms