dma_map_sg_attrs(9)
β¨ dma_map_sg_attrs(9) β the Kernel API Manual glow-up β¨
okay bestie, so this one is from the Kernel API Manual and it's literally all about mapping a buffer for DMA. no cap, it's giving "scatterlist but make it direct memory access" and i'm obsessed. let's get into it π«Ά
πΈ SYNOPSIS πΈ
unsigned int dma_map_sg_attrs (struct device *dev , struct scatterlist
*sg , int nents , enum dma_data_direction dir , unsigned long attrs );
π ARGUMENTS π
devβ the device you're doing this whole DMA operation for, main character energy frsgβ thesg_tableobject that describes the buffer, like it's the blueprint bestienentsβ how many entries you wanna map, count 'emdirβ the DMA direction, iykykattrsβ optional DMA attributes for the map operation, the little extra sparkle β¨
π DESCRIPTION π
so basically this maps a buffer that's described by a scatterlist β that's the one passed in the sg argument β with nents segments for the dir DMA operation, all done by the dev device. slay.
it returns the number of mapped entries on success, and lowkey that number can be less than nents, so don't come for it. if anything goes wrong? zero. that's it. zero. π«
π¨ important bestie, listen up: you gotta usedma_unmap_sg_attrsto unmap the buffer, and you use the originalsgand the originalnentsβ not the value this function returned. the way that matters. don't mix it up or it's gonna be a whole situation π
π₯ SEE ALSO π₯
- Kernel file
./kernel/dma/mapping.c dmam_free_coherent(9)dmam_alloc_attrs(9)dma_map_sgtable(9)dma_need_unmap(9)dma_can_mmap(9)dma_mmap_attrs(9)dma_addressing_limited(9)
like, go read those too, they're all part of the same friend group fr fr π
and that's the tea π this page is from ./kernel/dma, dated October 2026, and the manpage version is dma_map_sg_attrs(9). periodt. go map some buffers bestie, you got this ππ¦π
π¦ 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