OpenDGPS / zynq-axi-dma-sg

Simple C snippet to transfer DMA memory with scatter/gather on a Zynq 7020
52 stars 28 forks source link

Only poll #3

Open DarrenChengdu opened 7 years ago

DarrenChengdu commented 7 years ago

@OpenDGPS By use mapping of "/dev/mem" and its offset, only poll the status of corresponding registers can achieve whether read/write is ready, just like what you do in function "wait_for_sync". Can interupts be utilized in your work?

OpenDGPS commented 7 years ago

You're right, it would be better - at least in sense of style - to use interupts. Particular if the MEMBLOCK_WIDTH is huge, the transfer will consume many polling cycles. After several tries I came to the conclusion using interupts for this particular use case (reading a stream from memory, doing calculations inside the PL, writing back to another memory) needs to be done step by step. It failed in all atempts where aditional hardware comes in. The results in the target memory implicate an interference with the cache. I would assume that the MMU needs its time to trigger an interrupt. This also happens in some circumstances if the process is not bounded to an dedicated core (taskset -1).

fpgaioc commented 7 years ago

Hi OpenDGPS,

Thank you for sharing this good idea. This is much simpler than writing a custom client driver to interface between the Xilinx driver and the user app.

I am trying to convert your idea to a simple all-in-one character driver, I got the scatter engine to start, and the interrupt to fire, but only once, and with error -- the status word is 0x15219.

It seems I did not fill the descriptor list properly. If possible please advice on:

  1. how do we gain access to the HP0_DDR_LOWOCM in Linux?
  2. how to allocate the buffers for the DMA, dma_alloc_coherent or kmalloc then dma_map...?

Thank you very much, best regards,