dma_free_contiguous(9)
π dma_free_contiguous β like, the kernel API manual, section 9, bestie π
Okay so before we even start β this is from the Kernel API Manual, section 9, and yes we are absolutely getting into it. Sit down, grab a strawberry π, and let's talk about giving memory back.
β¨ NAME β¨
dma_free_contiguous β release allocated pages π
Like, it's the cleanup crew. The "ok bestie, party's over, everybody out" of contiguous DMA pages. No cap.
π¦ SYNOPSIS π¦
void dma_free_contiguous (struct device *dev , struct page *page ,
size_t size );
That's it. That's the whole vibe check. Three things in, nothing out β it returns void, so don't be out here expecting a status report. π
πΈ ARGUMENTS πΈ
devβ Pointer to the device for which the pages were allocated. Like, which device's memory are we handing back? Gotta be specific, bestie. πpageβ Pointer to the allocated pages. This is the actual stuff you're freeing. Your main character. β¨sizeβ Size of allocated pages. Yes, you have to tell it how much. It's not a mind reader. π
π DESCRIPTION π
So here's the tea, fr fr: this function releases memory that was allocated by dma_alloc_contiguous. It's the β¨ reverse β¨ of that one. Cleanup arc. We love to see it. π§
Now, the way it actually works is genuinely kind of iconic: cma_release returns false when the pages you provided do not belong to the contiguous area, and true otherwise. So the function checks that return value, and β plot twist β upon a false-return it does a fallback __free_pages. π«Ά
Lowkey important: that false path means your pages weren't from the contiguous area, so it just frees them the regular way instead. Not me being dramatic β that's literally what the manpage says. π
So: true β CMA handled it. false β fallback __free_pages swings in and saves the day. Either way, the pages get freed. Slay. π₯
β SEE ALSO β
- Kernel file
./kernel/dma/contiguous.cπ (yes, that's where the source lives) dma_contiguous_get_area_by_idx(9)dma_contiguous_reserve(9)dma_contiguous_reserve_area(9)dma_alloc_from_contiguous(9)dma_release_from_contiguous(9)dma_alloc_contiguous(9)
All the siblings. The whole contiguous-family group chat. π
Okay that's the whole page, bestie β no filler, all facts. This lil' beauty comes to you courtesy of the source path ./kernel/dma, dated October 2026, in section 9 of the Kernel API Manual. Go free your pages responsibly. ππ
π¦
π¦ 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