gfp_t flag,unsigned long attrs){conststruct dma_map_ops*ops=get_dma_ops(dev);void*cpu_addr;BUG_ON(!ops);if(dma_alloc_from_dev_coherent(dev,size,dma_handle,&cpu_addr))returncpu_addr;if(!arch_dma_alloc_attrs(&dev,
.map_resource = iommu_dma_map_resource, .unmap_resource = iommu_dma_unmap_resource, .mapping_error = iommu_dma_mapping_error, }; 非iommu的话即调用__dma_alloc: static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flags, unsigned long attrs) { ...
没有IOMMU的DMA操作会有什么影响? 我们知道DMA通常需要访问连续的物理内存,除非设备支持iommu,当设备不支持iommu的话可以用以下方式: 在内核启动时为设备保留内存 将MMU内嵌到设备中,如GPU 这里GPU MMU的方式算是个例外,不在本篇文章讨论范围内。 我们知道DMA映射有两种方式,一种是一致性映射 dma_alloc_coherent,一...
我们知道DMA映射有两种方式,一种是一致性映射 dma_alloc_coherent,一种是流式映射 dma_map_single (dma_map_sg可以映射多个dma buffer)。 一致性映射 dma_alloc_coherent dma_alloc_coherent会调用dma_alloc_attrs: dma_alloc_coherent->dma_alloc_attrs->swiotlb_alloc->(ma_direct_alloc/swiotlb_alloc_buffer)...
没有IOMMU的DMA操作 我们知道DMA通常需要访问连续的物理内存,除非设备支持iommu,当设备不支持iommu的话可以用以下方式: 在内核启动时为设备保留内存 将MMU内嵌到设备中,如GPU 这里GPU MMU的方式算是个例外,不在本篇文章讨论范围内。 我们知道DMA映射有两种方式,一种是一致性映射 dma_alloc_coherent,一种是流式映射...
没有IOMMU的DMA操作 我们知道DMA通常需要访问连续的物理内存,除非设备支持iommu,当设备不支持iommu的话可以用以下方式: 在内核启动时为设备保留内存 将MMU内嵌到设备中,如GPU 这里GPU MMU的方式算是个例外,不在本篇文章讨论范围内。 我们知道DMA映射有两种方式,一种是一致性映射 dma_alloc_coherent,一种是流式映射...