attach函数:
This is called from dma_buf_attach() to make sure that a given &dma_buf_attachment.dev can access the provided &dma_buf. Exporters which support buffer objects in special locations like VRAM or device-specific carveout areas should check whether the buffer could be move to system memory (or directly accessed by the provided device), and otherwise need to fail the attach operation.
The exporter should also in general check whether the current allocation fulfills the DMA constraints of the new device. If this is not the case, and the allocation cannot be moved, it should also fail the attach operation. Any exporter-private housekeeping data can be stored in the &dma_buf_attachment.priv pointer.
绿色代表输入参数,淡蓝色代表结构体包括的内容
1、分配一块临时内存,这块内存,赋值给输入参数struct dma_buf_attachment *attachment 的私有数据,并回传
同时将dev也传入到dma_heap_attachment中
2、对内存中的数据进行整理,输入参数dmabuf的sg_table做一次dup,然后赋值给临时内存dma_heap_attachment的table
这样这个attchment对应的table就有了,同样dmabuf也有了
3、buffer维护的attachments的list,添加这个新的attachment信息