bperez77 / xilinx_axidma

A zero-copy Linux driver and a userspace interface library for Xilinx's AXI DMA and VDMA IP blocks. These serve as bridges for communication between the processing system and FPGA programmable logic fabric, through one of the DMA ports on the Zynq processing system. Distributed under the MIT License.
MIT License
464 stars 227 forks source link

Question about asynchronous transfer return value #142

Open ThomasMGilman opened 2 years ago

ThomasMGilman commented 2 years ago

Hi, I am trying to take advantage of our systems SG mode by using your library to perform multiple calls on axidma_oneway_transfer with the usage of a callback previously set for the specified Rx channel. I understand that the callback should be immediately called upon the completion of the requested transfer amount. My question is whether or not we are able to retrieve the returned value of the ioctl in the instance of the function being non-blocking; similarly to a std::future? My reasoning is for the cases where the DMA transfer fails and I need to log the failure and perform additional actions on the buffer before it is used again.

So would something such as the below be possible?

//All handled by a separate thread/process
SomeClass::performOneWayTransfer
(uint dmaChannel, dma_transfer* dmaTransfer) {
  future<int> transferResult = async(
  axidma_oneway_transfer, SomeClass::StaticAxidmaHandler.axidmaDev, 
  dmaChannel, dmaTransfer->outputBuf, dmaTransfer->amountToTransfer, false);
  transferResult.wait();
  if((result = transferResult.get()) != 0){
     ...//log the failure and other stuff