08-28-2014 06:14 AM
I am debugging a user mode Linux app that uses AXI dma. I made a 128Mbyte DRAM memory hole which Linux does not use and I mmap() it in. I can then use this memory for buffers for dma to my logic. The data is written into the buffers by the processor, then read from the buffers by the AXI DMA (I use the S_AXI_GP0 port on the processor system). Everything runs but the data is not consistent. I wonder if this is a caching problem, the processor has data cache but the AXI_DMA is uncached so maybe it reads stale data. Is there a way to flush the cache in a Linux user space app, or should I use maybe the ACP port for the AXI_DMA?
08-28-2014 06:30 AM
I personally find that user space DMA without a kernel driver is going to be very challenging as you don't have good cache control and buffer management IMHO. But I could be corrected if someone has data that differs from that.
Are you using /dev/mem?, I assume it's mapping that memory in as cached based on your issues. If you used the UIO framework (even without a kernel driver) then it could treat that memory as I/O (slower) but then it could be coherent without any caching issues I believe. The UIO framework is really easy to use, not hardly any more work that /dev/mem.
I'm working on an example similar to this and here's my thoughts, but I'm open to suggestions as I'm not an expert on it. I am using a small kernel driver that is a char device (for ioctl support), a UIO device (to allow mmap with user space), and a client of the DMA Engine framework which the AXI DMA driver is part of. This driver takes care of cache control so that DMA buffers are consistent.
The driver allocates a kernel buffer using kmalloc such that it's cached. The memory is a block that is shared memory with a user space app that is UIO based with mmap. The user space application read/writes data and control/status to the block and then uses iotcl to start the DMA transfer.
Great conversation, I like these threads as we all learn,
08-28-2014 06:59 AM
08-28-2014 07:16 AM
I guess my 'quick and dirty' approach is because I am a hardware engineer that dabbles in software so I don't want to touch kernel programming.
Can you post a link to UIO framework and I will check it out.
Meanwhile I am going to try again using the ACP port for the AXI DMA.
08-28-2014 10:46 AM