On Wed, Aug 10, 2011 at 7:11 AM, Sumit Semwal sumit.semwal@ti.com wrote:
+/**
- struct dma_buf_ops - operations possible on struct dmabuf
- @get_scatterlist: returns list of scatter pages allocated, increases
- usecount of the buffer
- @put_scatterlist: decreases usecount of buffer, might deallocate scatter
- pages
- @mmap: map this buffer
- @read: read from this buffer
- @write: write to this buffer
- @release: release this buffer; to be called after the last dma_buf_put
- @sync_sg_for_cpu: sync the sg list for cpu
- @sync_sg_for_device: synch the sg list for device
- */
+struct dma_buf_ops {
- /* allow buffer to not be pinned when DMA is not happening */
- struct scatterlist * (*get_scatterlist)(struct dma_buf *);
- void (*put_scatterlist)(struct dma_buf *, struct scatterlist *);
One thought, {get,put}_scatterlist() gives the allocating driver half of what it needs to implement a sync object.. ie. if receiving driver does a "get" before DMA, and "put" on completion, this tells the allocating driver that the buffer is in use. If we added an 'op' to get_scatterlist which was READ &/| WRITE this would even tell the allocator the nature of the DMA which could later be used to implement a wait(op).
Another thought.. at the risk of re-opening a can of worms.. an 'attrib' flag/mask as a param to get_scatterlist() could allow the allocator to defer backing the buffer w/ real memory until the first get_scatterlist() call, for now attrib flag could be discontig, contig, and weird (as Hans suggested) and we can try to define more precisely "weird" later but for now can have platform specific meaning perhaps. This gives a sort of "poor mans negotiation" which might help on some platforms for now..
BR, -R
- /* allow allocator to mmap/read/write to take care of cache attrib */
- int (*mmap)(struct dma_buf *, struct vm_area_struct *);
- ssize_t (*read)(struct dma_buf *, void *, size_t);
- ssize_t (*write)(struct dma_buf *, void *, size_t);
- /* after final dma_buf_put() */
- void (*release)(struct dma_buf *);
- /* allow allocator to take care of cache ops */
- void (*sync_sg_for_cpu) (struct dma_buf *, struct device *);
- void (*sync_sg_for_device)(struct dma_buf *, struct device *);
+};