struct scatterlist、struct sg_table
struct scatterlist {
unsigned long page_link;
unsigned int offset;
unsigned int length;
dma_addr_t dma_address;
#ifdef CONFIG_NEED_SG_DMA_LENGTH
unsigned int dma_length;
#endif
};
struct sg_table {
struct scatterlist *sgl; /* the list */
unsigned int nents; /* number of mapped entries */
unsigned int orig_nents; /* original size of list */
};
struct dma_buf、struct dma_buf_attachment、struct dma_buf_ops
struct dma_buf {
size_t size;
struct file *file;
struct list_head attachments;
const struct dma_buf_ops *ops;
struct mutex lock;
unsigned vmapping_counter;
struct dma_buf_map vmap_ptr;
const char *exp_name;
const char *name;
spinlock_t name_lock;
struct module *owner;
struct list_head list_node;
void *priv;
struct dma_resv *resv;
wait_queue_head_t poll;
struct dma_buf_poll_cb_t {
struct dma_fence_cb cb;
wait_queue_head_t *poll;
__poll_t active;
} cb_in, cb_out;
#ifdef CONFIG_DMABUF_SYSFS_STATS
struct dma_buf_sysfs_entry {
union {
struct kobject kobj;
struct work_struct sysfs_add_work;
};
struct dma_buf *dmabuf;
} *sysfs_entry;
#endif
ANDROID_KABI_RESERVE(1);
ANDROID_KABI_RESERVE(2);
};
通过dma_buf_export创建dma buf;
通过dma_buf_fd创建文件描述符;
通过dma_buf_put()和get_dma_buf()对dma buf进行引用计数;
通过struct dma_buf_attachment访问设备DMA;
size:buffer的大小,在buffer的生命周期内保持不变。
file:文件指针,用于引用计数。
attachments:dma_buf_attachment列表,表示所有连接的设备。
ops:操作函数
vmapping_counter:vmap的计数
vmap_ptr:虚拟地址
exp_name:exporter名字
name:用户层提供的名字
owner:指向exporter模块
priv:exporter私有数据
struct dma_buf_attachment {
struct dma_buf *dmabuf;
struct device *dev;
struct list_head node;
struct sg_table *sgt;
enum dma_data_direction dir;
bool peer2peer;
const struct dma_buf_atta