通常在使用consistent dma mapping时,首先需要通过dma_alloc_coherent接口来分配一段区域: dma_alloc_coherent用于分配coherent内存,并返回对应的虚拟地址; 进行内存分配时,存在三种方式: 1)优先从设备专用的dma池开始分配; 2)无专用dma池,如果是dma-direct访问,通过dma_direct_alloc分配,而底层是依赖于CMA来分配; 3)...
所以我们使用DMA API的使用,不应该使用总线相关的API,比如使用dma_map_(),而非pci_map_()接口。 在我们的驱动程序里,应该包含头文件linux/dma-mapping.h,这个头文件提供了dma_addr_t的定义。dma_addr_t可以提供对任何平台的dma地址的支持。 内存的DMA可用性 哪些内存可以被用作DMA?有一些不成文的规则。 使用...
但在许多其他系统中,IOMMU 硬件会将 DMA 地址转换为物理地址,例如将 Z 转换为 Y、 这也是 DMA API 的部分原因:驱动程序可以将虚拟地址 X 交给 dma_map_single()之类的接口,该接口会设置所需的 IOMMU 映射,并返回 DMA 地址 Z。 So that Linux can use the dynamic DMA mapping, it needs some help from...
一致性 DMA ,在 DMA 内存申请的过程中,首先进行一个 ioremap_nocache 的映射,然后调用函数 dma_cache_wback_inv 保证缓存已经刷新到位之后,后面使用这一段内存时不存在一二级缓存; 流式DMA ,不能直接禁止缓存,因为流式 DMA 可以使用系统中的任意地址范围的地址,CPU 总不能将系统所有的地址空间都禁止缓存,这不...
if (*dma_handle == DMA_MAPPING_ERROR) { dma_free_contiguous(dev, page, size); return NULL; @@ -86,7 +91,10 @@ void dma_common_free_pages(struct device *dev, size_t size, struct page *page, { const struct dma_map_ops *ops = get_dma_ops(dev);if...
The implementation of dma_map_single() and dma_unmap_single() is exactly the same for all the architectures that support them. Factor them out to <linux/dma-mapping.h>, and make all drivers to include <linux/dma-mapping.h> instead of <asm/dma-mapping.h>. If we need to differentiate...
两种类型的DMA mapping:一致性DMA映射&流式DMA映射 (5.10),一致性DMA:在驱动初始化时mapping,在驱动shutdown时unmapping**(意味着不是一次性的,是持续性的使用该DMA映射)**。硬
顺便说明一点:DMA API适用于各种CPU arch,各种总线类型,DMA mapping framework已经屏蔽了底层硬件的细节。对于驱动工程师而言,你应该使用通用的DMA API(例如dma_map_*() 接口函数),而不是和特定总线相关的API(例如pci_map_*() 接口函数)。 驱动想要使用DMA mapping framework的API,需要首先包含相关头文件: ...
Part I - dma_API To get the dma_API, you must #include <linux/dma-mapping.h>. This provides dma_addr_t and the interfaces described below. 要获得 dma_API,必须 #include <linux/dma-mapping.h>。它提供了 dma_addr_t 和下面描述的接口。
* generic DMA mapping code. 32-bit only devices (if not handled by an IOMMU * anyway) will take a first dip into ZONE_NORMAL and get otherwise served by * ZONE_DMA. @@ -252,13 +252,12 @@ void __init paging_init(void)