For more detailed description, refer Documentation/DMA-mapping.txt.
- Consistent DMA mappings
- Synchronous, coherent
- No cache coherence issue
- Limited resource, CONSISTENT_DMA_SIZE(usually 2MB)
- Slow in access, access to memory directly
- Non-cacheable, Non-bufferable(NCNB)
- Function
- Buffer allocation/free: pci_alloc_consistent/pci_free_consistent, dma_alloc_coherent/dma_free_coherent
- Streaming DMA mappings
- Cacheable, Bufferable buffer
- faster, more in quantity (compare to Consistent DMA mappings)
- Has cache coherence issue
- Flush the cache, write data to memory (PCI_DMA_TODEVICE) when:
- After software changes the content of the DMA buffer
- Before DMA start
- After software changes the content of the DMA buffer
- Invalidate the cache, read data from memory (PCI_DMA_FROMDEVICE) when:
- Before reading the DMA buffer
- After DMA stop
- Before reading the DMA buffer
- Flush the cache, write data to memory (PCI_DMA_TODEVICE) when:
- Function
- Buffer allocation/free: kmalloc/kfree
- Map/Unmap: pci_map_single/pci_unmap_single, dma_map_single/dma_unmap_single
- Cache coherence : dma_sync_single/pci_dma_sync_single/... (PCI_DMA_TODEVICE/PCI_DMA_FROMDEVICE)
* It seems that cache invalidate will NOT clean the cached write buffer; if there are memory writes without cache flush, even cache invalidation is done after device DMA, the data read may still be the previous cached memory write. So ensure the cache is flushed properly before device starting DMA. (by experience, ARM11MPCore)
沒有留言:
張貼留言