Cache Coherent 非一致性内存解决与验证

1        摘要

使用J6平台开发项目中,使用DMA拷贝数据,针对DMA物理内存和Cache的一致性进行测试和验证。

2        解决方法和目的

方法目的:使用dma_sync_single_for_device();dma_sync_single_for_cpu()对内存进行一致性管理,通过下文的介绍可以正确使用这两个函数。

方法验证:

A.    验证Cache与DMA存在不一致的问题。

B.     dma_sync_single_for_device();dma_sync_single_for_cpu()对物理内存和Cache的实际操作内容。

C.     验证函数效率。

2.1     INV和CLEAN概念

invalidate清除cache的意思是清除cache中存储的全部数据。对处理器而言,清除操作只要清零相应cache行的有效位即可。当存储器配置上有变化时,整体或部分cache可能需要进行清除操作。
      clean清理cache的意思是把脏的(即被改写过的)cache强制写到主存,并把cache行中的脏位清零。清理cache可以重建cache与主存之间的一致性,它只用在使用写回策略的D-cache上。
       

2.2     测试使用程序列表

名称

功能

Dmatest

测试应用程序

omap_ds_dma.ko

测试对应驱动程序

 

2.3     测试程序命令列表

命令名称

功能

@cc  <n>

Set cache on(1)/off(0)驱动内DMA的cache管理功能

@ccsrc [size]

Make src cached

@ccdst [size]

Make dst cached

@ccsrcn [size]

Make src cached write 0x66

@ccdstn [size]

Make src cached write 0x33

@up

Update src dynamic val

@dmacp

Dma Cp test 0x1000 DMAsrc->dst拷贝4K

@dmacp1

Dma Cp test max DMAsrc->dst拷贝8M

@dmacpn <n>

Dma Cp test n times

@showm <addr>

Show Mem 0x----  test 显示物理地址内数据

@shows

Show Mem 0xAC000000

@showd

Show Mem 0xAC800000

@coset <val>

Set coherent data 设置Coherent驱动内缓冲区的值

@coshow

Show coherent data显示Coherent驱动内缓冲区的值

@setwb <paddr>

Set write back 设置指定区域的clean功能WB

@setinv <paddr>

Set invalide  设置指定区域的invalid功能

@cotocc

Coherent to cache Coherent to dst(cached) DMA拷贝

@cctoco

Cache to Coherent dst(cached) to Coherent 的DMA拷贝

@exit

 

@help

 

 

2.4     验证条件

a.      驱动程序提供一块一致性内存;

b.      使用物理内存0xAC000000~0xAC800000为src带cache内存。

c.      使用物理内存0xAC800000~0xAD000000为dst带cache内存

2.5     验证1一致性问题存在

使用DMA将no cache数据传送到cached内存,需要将目的内存进行cache,然后启动DMA,再查看目的内存的内容,结果会导致CPU与物理内存不一致

 

<UT>:coset 0x65

[61901.806422]

[D]Paddr:0xAB859000 Paddr:0xEB859000

[D]coset 0x65

=============BUFF MSG============

[D]  65  65 65  65  65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65  65

[D]  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65

[D]  65  65 65  65  65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65  65

[D]  65  65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65  65

[D]

[D]=============BUFF END============

<UT>:showd

showd

pMemDstVirtAddr is 0xB5E0C000

=============BUFF MSG============

  22  22 22  22  22 22  22  22 22  22  22 22  22  22 22  22  22 22  22  22 22  22  22 22  22  22 22  22  22 22  22  22

  22  22 22  22  22  22  22 22  22  22 22  22  22 22  22  22 22  22  22 22  22  22 22  22  22 22  22  22 22  22  22  22

  22  22  22  22 22  22  22 22  22  22 22  22  22 22  22  22 22  22  22 22  22  22 22  22  22 22  22  22 22  22  22  22

  22  22 22  22  22  22  22 22  22  22 22  22  22 22  22  22 22  22  22 22  22  22 22  22  22 22  22  22 22  22  22  22

 

=============BUFF END============

<UT>:cotocc

cotocc

func_get_coherent_arg ioctl paddr 0xab859000, size 0x00001000,

Dma Cp [0xAB859000] -> [0xAC800000] oK,Use time: 1009 us

<UT>:showd

showd

pMemDstVirtAddr is 0xB5E0C000

=============BUFF MSG============

  65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65  65 65  65

 65  65  65 6

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值