dma_buf_begin_cpu_access(9)
π dma_buf_begin_cpu_access(9) β from the Kernel API Manual, bestie
Okay so real talk: this is a kernel API manual page, and the function it's about is dma_buf_begin_cpu_access(9). That's the whole vibe. Let's get into it β¨
πΈ NAME πΈ
dma_buf_begin_cpu_access β you must call this before you touch a dma_buf from the cpu while you're in kernel context, no cap. It calls begin_cpu_access so the exporter can do its little prep ritual. And heads up: coherency is only guaranteed inside the range you specified, for the access direction you specified. That's it. That's the deal π
β¨ SYNOPSIS β¨
int dma_buf_begin_cpu_access (struct dma_buf *dmabuf , enum
dma_data_direction direction );
π«Ά ARGUMENTS π«Ά
dmabuf[in] β the buffer you're prepping for cpu access. your main character πdirection[in] β which way the access is going. the direction of access, literally.
π DESCRIPTION π
So once your cpu access is done, the caller should call dma_buf_end_cpu_access. And listen β only when cpu access is bracketed by both of those calls is it guaranteed to be coherent with other DMA access. Both. Not one. Both. periodt π«Ά
This function will also wait for any DMA transactions that are tracked through implicit synchronization in dma_buf.resv. Slay. But for DMA transactions with explicit synchronization, this function will only ensure cache coherency β that's it. Callers must ensure synchronization with those DMA transactions on their own. iykyk, that part's on you π§
Lowkey important: it can return negative error values, and it returns 0 on success. Check your return value bestie, don't just vibe past it π
π₯ SEE ALSO π₯
Kernel file ./drivers/dma-buf/dma-buf.c, plus the whole friend group:
dma_buf_iter_begin(9)dma_buf_iter_next(9)implicit fence polling(9)dma_buf_set_name(9)dma buf device access(9)dma_buf_export(9)dma_buf_fd(9)dma_buf_fd_install(9)dma_buf_get(9)dma_buf_put(9)locking convention(9)dma_buf_dynamic_attach(9)dma_buf_attach(9)dma_buf_detach(9)dma_buf_pin(9)dma_buf_unpin(9)dma_buf_map_attachment(9)dma_buf_map_attachment_unlocked(9)dma_buf_unmap_attachment(9)dma_buf_unmap_attachment_unlocked(9)dma_buf_attach_revocable(9)dma_buf_invalidate_mappings(9)cpu access(9)dma_buf_end_cpu_access(9)dma_buf_mmap(9)dma_buf_vmap(9)dma_buf_vmap_unlocked(9)dma_buf_vunmap(9)dma_buf_vunmap_unlocked(9)
and that's the page, bestie π¦ go forth and bracket your cpu access π
this gem lives in ./drivers/dma-buf, dated October 2026 β mwah, love that for us π
π¦ 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