cache coherency when using dma

来源:互联网 发布:淘宝外贸鞋店推荐 编辑:程序博客网 时间:2024/05/16 11:55

linux提供两种方式,来保证使用dma时,内存和硬件cache的一致性:

1.Coherent DMA mapping

When using this mapping, the kernel ensures that there will be no cache coherency problems between the memory and the hardware device; this means that every write operation performed by the CPU on a RAM location is immediately visible to the hardware device, and vice versa. This type of mapping is also called "synchronous" or "consistent."


2.Streaming DMA mapping

When using this mapping, the device driver must take care of cache coherency problems by using the proper synchronization helper functions. This type of mapping is also called "asynchronous" or "non-coherent."

说白了,如果采用第一种方式的话,就是由kernel来保证一致性,驱动程序是不用考虑的,这种方法的缺点是

在某些体系结构上,效率很低;如果采用第二种方式的话,那么是有驱动程序来保证一致性的,所以当驱动

要使用dma来进行数据传输时,必须首先检测内存和硬件cache的一致性,linux提供了这类方法。