STRUCT DMA_BUF_ATTACHMENT(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 of dma_buf_attachment, and it's protected by the dma_resv lock of the dmabuf. do not touch it without that lock, i'm literally begging πŸ™ˆ
  • peer2peer β€” true if 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_attachment must be called with the dma_resv lock 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:


🫢 and that's the whole page! sourced straight from ./include/linux, dated October 2026, for struct dma_buf_attachment(9). slay, go attach some buffers responsibly πŸ’–
πŸ“¦ where this page comes from