Posted Jan 12, 2012 16:48 UTC (Thu) by robclark (subscriber, #74945)
Parent article: DMA buffer sharing in 3.3
just a very minor correction: attach()/detach() are not really for reference counting, that is handled with dma_buf_get()/dma_buf_put() (under the hood it is using 'struct file *' refcnting). Driver writers adding support for dmabuf should be sure to do a dma_buf_get() in their ioctl for importing the dmabuf, and keep the 'struct dma_buf *' ptr, rather than holding on to the file descriptor (int).
The attach()/detach() is really just advisory to the exporting driver to help it know the constraints of potentially multiple different devices that would be sharing the buffer. For example, a camera and encoder might share a single buffer w/ display/gpu.