STRUCT DMA_BUF_ATTACHMENT(9)
π struct dma_buf_attachment(9)
okay so bestie, welcome to the Kernel API Manual β yes, the real one, the one that lives in the kernel docs. we're talking about struct dma_buf_attachment today and honestly? she's kind of the main character of buffer sharing. let's get into it π«Ά
β¨ NAME β¨
struct dma_buf_attachment β holds device-buffer attachment data. that's it, that's the whole vibe: it's the little struct that keeps track of who's attached to the buffer π
πΈ SYNOPSIS πΈ
struct dma_buf_attachment {
struct dma_buf *dmabuf;
struct device *dev;
struct list_head node;
bool peer2peer;
const struct dma_buf_attach_ops *importer_ops;
void *importer_priv;
void *priv;
};
copy that exactly, no cap, character for character π
π Members π
okay the field-by-field breakdown, because every single one of these matters:
dmabufβ the buffer for this attachment. the actual star of the show π¦devβ the device that's attached to the buffer. hi bestie, welcome to the party πnodeβ the list ofdma_buf_attachment, and it's protected by thedma_resvlock of thedmabuf. do not touch it without that lock, i'm literally begging πpeer2peerβtrueif the importer can handle peer resources without pages. fancy. iconic. love that for her βimporter_opsβ importer operations for this attachment. and lowkey important: if provided,dma_buf_map/unmap_attachmentmust be called with thedma_resvlock held. don't skip that part, i'm serious πimporter_privβ importer specific attachment data. hers, not yours πprivβ exporter specific attachment data. the other side's stash π
π₯ Description π₯
so like, what does she actually do? this structure holds the attachment information between the dma_buf buffer and its user device(s). the list contains one attachment struct per device attached to the buffer. one per device, periodt.
an attachment is created by calling dma_buf_attach, and released again by calling dma_buf_detach. that's the whole lifecycle, very demure of her β¨
and the DMA mapping itself β the thing you actually need to initiate a transfer β is created by dma_buf_map_attachment and freed again by calling dma_buf_unmap_attachment. map it, transfer, unmap it. the trinity. iykyk π§
π SEE ALSO π
go read these next, bestie, they're all in the kernel file ./include/linux/dma-buf.h:
struct dma_buf_ops(9)struct dma_buf(9)struct dma_buf_attach_ops(9)struct dma_buf_export_info(9)DEFINE_DMA_BUF_EXPORT_INFO(9)get_dma_buf(9)dma_buf_is_dynamic(9)
π«Ά and that's the whole page! sourced straight from./include/linux, dated October 2026, forstruct dma_buf_attachment(9). slay, go attach some buffers responsibly π
π¦ 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