- 论坛徽章:
- 0
|
回复 1# lyl19
在没有开启IOMMU功能时(Intel VT-d技术)时,内核对于DMA的sync统一使用的是flush_write_buffers函数- static void nommu_sync_single_for_device(struct device *dev,
- dma_addr_t addr, size_t size,
- enum dma_data_direction dir)
- {
- flush_write_buffers();
- }
- static void nommu_sync_sg_for_device(struct device *dev,
- struct scatterlist *sg, int nelems,
- enum dma_data_direction dir)
- {
- flush_write_buffers();
- }
- struct dma_map_ops nommu_dma_ops = {
- .alloc_coherent = dma_generic_alloc_coherent,
- .free_coherent = nommu_free_coherent,
- .map_sg = nommu_map_sg,
- .map_page = nommu_map_page,
- .sync_single_for_device = nommu_sync_single_for_device,
- .sync_sg_for_device = nommu_sync_sg_for_device,
- .is_phys = 1,
- };
复制代码 在flush_write_buffer函数中会进行锁总线并对目标地址进行加0操作以同步cache与内存之间的内容- static inline void flush_write_buffers(void)
- {
- #if defined(CONFIG_X86_OOSTORE) || defined(CONFIG_X86_PPRO_FENCE)
- asm volatile("lock; addl $0,0(%%esp)": : :"memory");
- #endif
- }
复制代码 因此,对于no-cache类型的内存,cpu在执行这条指令时少了个写入cache的动作,会比标志cache的内存快一点点
|
|