目录
2.3DMA Streaming Mapping 流式DMA映射
3.4dma_mask 与 coherent_dma_mask 的定义
3.5dma_alloc_coherent 分配的内存一定在 DMA ZONE 内吗?
3.6dma_alloc_coherent() 申请的内存是非 cache 的吗?
1.PCIe Dma coherent前言
HOST主桥与主存存储器来同一级内部高速总线上,方便PCI设备通过HOST主桥访问主存储器,即进行DMA操作。
值得注意的是,PCI设备的DMA操作需要处理器系统的Cache进行一致性操作。当PCI设备通过HOST主桥访问主存储器时,Cache一致性模块将进行地址监听,并根据监听结果改变Cache状态。
Linux对cache一致性有两种管理方式:1. mem 硬件上uncache 2. 使用过程中,通过flush cache 保证data 一致性。
使用大块DMA一致性内存,此操作分配的内存大小有限制,如最小分配一个页:
dma_alloc_coherent dma_zalloc_coherent 分配dma使用的内存,并返回内存的物理地址及对应虚拟地址,与其他内存分配函数不同必须在中断使能的情况下使用
dma_free_coherent 释放dma_alloc_coherent分配的内存。
使用小块DMA一致性内存,先创建dma内存池,然后在内存池中分配小内存:
struct dma_pool* dma_pool_create(const char *name, struct device