dma_free_noncoherent(structdevice *dev,size_tsize,void*cpu_addr, dma_addr_tdma_handle,enumdma_data_direction dir) 释放先前使用 dma_alloc_noncoherent() 分配的内存区域。dev、size、dma_handle 和 dir 必须与传递给 dma_alloc_noncoherent() 的参数相同。cpu_addr 必须是 dma_alloc_noncoherent() 返...
void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t dma) 最后,以上流程中还需要考虑一致性DMA所能支持的寻址范围,并使分配的内存地址位于寻址范围之内。其中一致性映射接口的寻址范围可通过以下接口设置: inline int dma_set_mask_and_coherent(struct device *dev, u64 mask) 流式DMA的...
voiddma_free_noncoherent(struct device *dev, size_t size, void *cpu_addr,dma_addr_t dma_handle, enum dma_data_direction dir) 释放先前使用 dma_alloc_noncoherent() 分配的内存区域。dev、size、dma_handle 和 dir 必须与传递给 dma_alloc_noncoherent() 的参数相同。cpu_addr 必须是 dma_alloc_no...
dma_free_noncoherent(struct device *dev, size_t size, void *cpu_addr, dma_addr_t dma_handle) 释放由非一致性API申请的内存。 int dma_get_cache_alignment(void) 返回处理器高速缓存对齐值。应该注意在你打算映射内存或者做局部映射时,该值为最小对齐值。 注意:该API可能返回一个比实际缓存行的大的值...
.alloc_noncoherent = iommu_dma_alloc_noncoherent, .free_noncoherent = iommu_dma_free_noncoherent, .mmap = iommu_dma_mmap, .get_sgtable = iommu_dma_get_sgtable, .map_page = iommu_dma_map_page, ---(2) .unmap_page = iommu_dma_unmap...
dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, dma_addr_t dma_handle) 释放之前申请的一致性内存。dev, size及dma_handle必须和申请一致性内存的函数参数相同。cpu_addr必须为申请一致性内存函数的返回虚拟地址。 注意:和其他内存分配函数不同,这些函数必须要在中断使能的情况下使用。
dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t gfp) { void *ret; if (!dev || *dev->dma_mask >= 0xffffffffUL) gfp &= ~GFP_DMA; ret = (void *)__get_free_pages(gfp, get_order(size)); //(1) ...
许多驱动程序需要大量小型DMA一致性内存区域,用于DMA描述符或I/O缓冲区。与使用dma_alloc_coherent()以页面或更大单位分配不同,您可以使用DMA池。这些工作方式类似于struct kmem_cache,但它们使用DMA一致性分配器,而不是__get_free_pages()。此外,它们了解对齐的常见硬件约束,比如队列头需要在N字节边界上对齐。
dma_free_noncoherent(dev, H2_BUF_SIZE, codec->buffer, codec->buffer_dma, buffer_dir); }static const struct snd_pcm_hardware hal2_pcm_hw = { @@ -509,21 +512,16 @@ static int hal2_playback_open(struct snd_pcm_substream *substream) ...
The coherent mask will always be able to set the same or a smaller mask as the streaming mask. However for the rare case that a device driver only uses consistent allocations, one would have to check the return value from dma_set_coherent_mask().一致性掩码总是能够设置与流掩码相同或更小...