免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 10531 | 回复: 7

pci_dma_sync_single_for_cpu到底同步的是什么? [复制链接]

论坛徽章:
7
丑牛
日期:2013-10-18 14:43:21技术图书徽章
日期:2013-11-03 09:58:03辰龙
日期:2014-01-15 22:57:50午马
日期:2014-09-15 07:04:39丑牛
日期:2014-10-16 14:25:222015年亚洲杯之伊朗
日期:2015-03-16 10:24:352015亚冠之城南
日期:2015-05-31 09:52:32
发表于 2008-03-28 16:22 |显示全部楼层
看了Documentation/DMA-mapping.txt这篇文档还是没明白,可能是e文太差了。。

论坛徽章:
0
发表于 2008-03-28 16:51 |显示全部楼层
原帖由 smalloc 于 2008-3-28 16:22 发表
看了Documentation/DMA-mapping.txt这篇文档还是没明白,可能是e文太差了。。

If you need to use the same streaming DMA region multiple times and touch
the data in between the DMA transfers, the buffer needs to be synced
properly in order for the cpu and device to see the most uptodate and
correct copy of the DMA buffer.

So, firstly, just map it with pci_map_{single,sg}, and after each DMA
transfer call either:

        pci_dma_sync_single_for_cpu(dev, dma_handle, size, direction);

or:

        pci_dma_sync_sg_for_cpu(dev, sglist, nents, direction);


由于single和sg都是streaming mapping, 所以硬件并不保证RAM──那块DMA buffer──和 CPU片上Cache之间的数据同步。  如果你对同一块buffer 做2次map, 而且又想在这2次map中间的时候,从CPU 碰碰它,就得自己负责 数据一致性。


所以,流程是:

1) pci_map_single
2) pci_dma_sync_single_for_cpu
3) 尽情的读写这块内存
4)pci_dma_sync_single_for_device
5)第2次对同一块buffer进行pci_map_single

论坛徽章:
0
发表于 2008-03-28 16:52 |显示全部楼层
PS, X86的内存全都是consistent的, 即使你用streaming DMA。

有些arch, 如MIPS, 不保证cache一致性,因此consistent内存就必须得是uncacheable的内存。

论坛徽章:
0
发表于 2008-03-30 21:28 |显示全部楼层
原帖由 albcamus 于 2008-3-28 16:52 发表
PS, X86的内存全都是consistent的, 即使你用streaming DMA。


虽然这么说  但在e100的x86的驱动里还是使用了pci_dma_sync_single_for_cpu  为什么呢?
http://tomoyo.sourceforge.jp/cgi ... /drivers/net/e100.c   1820 2154行

论坛徽章:
7
丑牛
日期:2013-10-18 14:43:21技术图书徽章
日期:2013-11-03 09:58:03辰龙
日期:2014-01-15 22:57:50午马
日期:2014-09-15 07:04:39丑牛
日期:2014-10-16 14:25:222015年亚洲杯之伊朗
日期:2015-03-16 10:24:352015亚冠之城南
日期:2015-05-31 09:52:32
发表于 2008-03-31 08:58 |显示全部楼层
原帖由 duanius 于 2008-3-30 21:28 发表


虽然这么说  但在e100的x86的驱动里还是使用了pci_dma_sync_single_for_cpu  为什么呢?
http://tomoyo.sourceforge.jp/cgi ... /drivers/net/e100.c   1820 2154行

a版主说的对,内核里对x86这个函数为空,什么也没做。

论坛徽章:
0
发表于 2008-03-31 11:44 |显示全部楼层
查了下 确实是这样   
既然怎么都是一致性映射  不知道是不是为了兼容性代码才写成这样

论坛徽章:
7
丑牛
日期:2013-10-18 14:43:21技术图书徽章
日期:2013-11-03 09:58:03辰龙
日期:2014-01-15 22:57:50午马
日期:2014-09-15 07:04:39丑牛
日期:2014-10-16 14:25:222015年亚洲杯之伊朗
日期:2015-03-16 10:24:352015亚冠之城南
日期:2015-05-31 09:52:32
发表于 2010-11-06 15:05 |显示全部楼层
又把这老帖翻上来
当年老A走的太快.我没跟上

现在回想起来,好象和2次pci_map_single没关系吧
k297499226 该用户已被删除
发表于 2015-04-11 14:42 |显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP