dma_buf_begin_cpu_access(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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:


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