mordorwww 发表于 2015-09-04 16:31

dma_alloc_writecombine什么意思

本帖最后由 mordorwww 于 2015-09-04 16:44 编辑

Dma_alloc_coherent allocated memory does not use the cache, it will not use the write buffer.


这个cache和write buffer什么关系和区别

源代码里的注释,什么叫uncached, buffered memory?

/**
* dma_alloc_writecombine - allocate write-combining memory for DMA
* @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
* @size: required memory size
* @handle: bus-specific DMA address
*
* Allocate some uncached, buffered memory for a device for
* performing DMA.This function allocates pages, and will
* return the CPU-viewed address, and sets @handle to be the
* device-viewed address.
*/
extern void *dma_alloc_writecombine(struct device *dev, size_t size,
                   dma_addr_t *handle, gfp_t gfp);



dma_alloc_coherent: consistency DMA mapping
dma_alloc_writecombine: streaming DMA mappings
Original dma_alloc_coherent would prohibit the ARM platform C Cacheable As with domain and B domain (bufferable) in the page table entry.
Only prohibits dma_alloc_writecombine C (Cacheable) domain.
# Define pgprot_noncached (prot) __ pgprot (pgprot_val (prot) & ~ (L_PTE_CACHEABLE | L_PTE_BUFFERABLE))
# Define pgprot_writecombine (prot) __ pgprot (pgprot_val (prot) & ~ L_PTE_CACHEABLE)
Further to find the ARM books, the original C represents whether to use the high-speed buffer memory, and W represents whether to use the write buffer.
, Dma_alloc_coherent allocated memory does not use the cache, it will not use the write buffer.
Dma_alloc_writecombine not use the cache, but the use of the write buffer.
That is consistent DMA mapping due to the closure cache / buffer, natural performance is relatively low. Streaming through a complex synchronization mechanism, without paying the cost of performance.
So we have to make use of streaming DMA programming.
Go take a look at the dispersion mmc driver / gather map, the original is also a streaming DMA mappings.

Talked about so much useless, summarize usage:
1, page-aligned memory size: dma_map_size = PAGE_ALIGN (MY_DATA_SIZE + PAGE_SIZE);
MY_DATA_SIZE is the size you want to assign.
2, the call
页: [1]
查看完整版本: dma_alloc_writecombine什么意思