jeremytrimble / ezdma

Simple, zero-copy DMA to/from userspace.
78 stars 29 forks source link

Does ezdma support contiguous memory ? #7

Open ranshalit opened 7 years ago

ranshalit commented 7 years ago

Hello,

Taking a look in ezsdk code I see it use SG dma method. Does it mean that it does not support dma_alloc_coherent (contiguous) memory allocation ?

Thank you, Ran

jeremytrimble commented 7 years ago

@ranshalit,

ezdma uses scatter-gather DMA so that contiguous allocations are not necessary (though, since SG DMA is more general than traditional "contiguous" DMA, you could use ezdma on contiguously-allocated memory, although I'm not sure how you'd guarantee that from a userspace program, which is where ezdma is intended to be used).

Note that dma_alloc_coherent() is intended to create a region of memory where caching is "turned off" -- so that writes from the CPU to memory are immediately visible to devices, and likewise so that writes from devices to memory are immediately visible to the CPU, so that explicit cache flushing and invalidation calls from software aren't required. This is orthogonal to the concept of contiguous/discontiguous memory.

ranshalit commented 7 years ago

Hi Jeremy, Thank you very much for the reply. I understand from this that ezdma can support both coherent or non coherent, Right ?

Another thing if I may: Is this package can be used in embedded and real-time applications (such as video capture) , i.e. I mean it terms of performance.

Thank you! Ran

jeremytrimble commented 7 years ago

Ran,

Keep in mind that ezdma is really designed to work with "slave DMA" devices -- e.g. ones like the Xilinx AXI DMA that support either writing data from the output of some hardware device (e.g. an FPGA IP core) into CPU RAM or reading data from the CPU RAM and presenting it to the input of some hardware device.

Though I haven't tested ezdma with it, I suspect you could also use it with the Analog Devices "dmac" IP core: HDL: https://github.com/analogdevicesinc/hdl/tree/master/library/axi_dmac Kernel Driver: https://github.com/analogdevicesinc/linux/blob/xcomm_zynq/drivers/dma/dma-axi-dmac.c

As for embedded/real-time applications, I don't see anything that would immediately make ezdma unusable for video capture, but it's all a question of what your throughput/latency requirements are. If the data you want to bring from your FPGA into software is presented as an AXI-Stream interface, then ezdma+Xilinx AXI DMA could be a workable solution for you.