免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1599 | 回复: 0
打印 上一主题 下一主题

[硬件及驱动] dma_alloc_writecombine什么意思 [复制链接]

论坛徽章:
9
程序设计版块每日发帖之星
日期:2016-02-13 06:20:00数据库技术版块每日发帖之星
日期:2016-06-15 06:20:00数据库技术版块每日发帖之星
日期:2016-06-16 06:20:00数据库技术版块每日发帖之星
日期:2016-06-18 06:20:00程序设计版块每日发帖之星
日期:2016-06-27 06:20:00程序设计版块每日发帖之星
日期:2016-07-09 06:20:00IT运维版块每日发帖之星
日期:2016-07-15 06:20:00IT运维版块每日发帖之星
日期:2016-07-27 06:20:00程序设计版块每日发帖之星
日期:2016-08-18 06:20:00
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-09-04 16:31 |只看该作者 |倒序浏览
本帖最后由 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.
[Supplement]
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
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP