dma_map_sg_attrs(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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 fr
  • sg β€” the sg_table object that describes the buffer, like it's the blueprint bestie
  • nents β€” how many entries you wanna map, count 'em
  • dir β€” the DMA direction, iykyk
  • attrs β€” 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 use dma_unmap_sg_attrs to unmap the buffer, and you use the original sg and the original nents β€” 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 πŸ”₯

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