This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM5728: linux 4.9.69 内核驱动通过dma将搬运到内存中,上层应用mmap将数据读取,上层读取到的数据和内核不一致。

Part Number: AM5728
Other Parts Discussed in Thread: AM4378

linux版本:linux 4.9.69

操作:内核驱动通过dma_alloc_coherent申请内存,然后通过dma将gpmc数据搬运到申请到的内存中,通过netlink将物理地址发送给上层应用程序,上层应用程序将地址mmap后把数据读取.

结果:上层读取到的数据和内核不一致。(内核将发送的地址数据存成文件,上层应用程序也将数据存成文件,将两个文件compare。)

初步分析:1.内核驱动通过dma_alloc_coherent申请内存,然后通过dma将gpmc数据搬运到申请到的内存中,在zmalloc一块地址,在

在通过virt_to_phys转换成物理地址。在把dma搬运到内存中的数据memcpy到新的zmalloc地址,再将地址发送给上层应用程序,结果数据是一样的。

2.对比出错的两个文件发现,出错的地方正是上一次的数据,初步怀疑是上层应用程序读取数据时,cache中的数据没有刷入内存中。

3.相同的操作在am4378上是没有问题的,但是4378上linux版本为4.1.18。

请帮忙分析一下吧,看看是哪里配置不正确吗?谢谢!