dma_sync_sgtable_for_cpu(9)
π dma_sync_sgtable_for_cpu(9) β like, the whole glow-up
okay so bestie, welcome to the Kernel API Manual β¨ this one is a single function that does one job and does it iconically β it hands a buffer back to the CPU so your code can actually touch it without the DMA engine side-eyeing you. no cap.
πΈ NAME πΈ
dma_sync_sgtable_for_cpu β Synchronize the given buffer for CPU access π«Ά
β¨ SYNOPSIS β¨
void dma_sync_sgtable_for_cpu (struct device *dev , struct sg_table *sgt
, enum dma_data_direction dir );
literally that's the whole vibe. three args, void return, no drama.
π ARGUMENTS π
devβ the device you're doing the DMA operation for. like, the main character of this whole thing πsgtβ thesg_tableobject that describes the buffer. it's the map, the receipt, the whole description ok πdirβ the DMA direction. which way the data's flowing, iykyk π
π¦ DESCRIPTION π¦
so what does it actually do? it performs the needed cache synchronization and moves the ownership of the buffer back to the CPU domain π₯ which means: it is safe to perform any access to it by the CPU. yes bestie, go ahead, read it, write it, it's yours now π
but listen β this is a handoff, not a forever thing. before doing any further DMA operations, one has to transfer the ownership of the buffer back to the DMA domain by calling the dma_sync_sgtable_for_device. don't ghost the DMA engine, it will Not be cute π
think of it like passing the aux cord back and forth π§ CPU has it now, but the second DMA wants a turn you must formally hand it over. no vibes-based ownership. periodt.
β SEE ALSO β
- Kernel file
./include/linux/dma-mapping.h dma_use_iova(9)dma_unmap_sgtable(9)dma_sync_sgtable_for_device(9)dma_get_seg_boundary_nr_pages(9)
all of these are lowkey the friend group of this function. go say hi πΈ
and that's the page, bestie!! π§ this lil' beauty lives in ./include/linux and it's dated October 2026, and yeah the page itself is dma_sync_sgtable_for_cpu(9) β slay, ate, no crumbs πβ¨π
π¦ 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