<div dir="ltr"><div><span style="font-family:monospace">Hey all,</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">As a newbie, I'm trying to figure out how to properly deal with timeouts for dma_engine_submit(). I'm using a """prototype""" kernel module that sits on-tops of the Xilinx AXIDMA driver as part of Xilinx's Linux fork. They do a good job of merging with upstream kernels but there are some Xilinx-specific things and I apologize if some information is hard to parse. I believe my question is generic to the DMA Engine framework. This module, called "dma-proxy" is discussed a lot by Xilinx forums members but information doesn't typically flow back to users where there are fixes. Aside from the "dma-proxy" driver, Xilinx also includes a "AXIDMA Test" driver. Both drivers sit atop of the Xilinx DMA driver and do various things. The "dma-proxy" does some sharing of memory between userspace and the kernel but that's not really important to my question.</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">First, this chain eventually resolves into `dma_engine_submit()`:</span></div><div><span style="font-family:monospace">-----------------------------------------------------------------<br></span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">(~ <a href="https://github.com/Xilinx-Wiki-Projects/software-prototypes/blob/master/linux-user-space-dma/Software/Kernel/dma-proxy.c#L198">https://github.com/Xilinx-Wiki-Projects/software-prototypes/blob/master/linux-user-space-dma/Software/Kernel/dma-proxy.c#L198</a>)<br><br>       sg_init_table(..., 1);<br>        sg_dma_address(... ) = foo.dma_handle;<br>        sg_dma_len(...t) = foo.length;<br>        chan_desc = dma_device->device_prep_slave_sg(..., ..., 1, ..., ..., NULL);</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace"> if (! chan_desc) {<br>     printk(KERN_ERR "dmaengine_prep*() error\n");</span></div><div><span style="font-family:monospace">else { ... }<br></span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">Then, the driver waits for the completion and prints an error if it cannot complete:<br></span></div><div><span style="font-family:monospace">-------------------------------------------------------------------------------------------------------------------<br></span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">     unsigned long timeout = msecs_to_jiffies(3000);<br>       timeout = wait_for_completion_timeout(foo.cmp, timeout);<br>      status = dma_async_is_tx_complete(..., ..., NULL, NULL);<br><br>    if (timeout == 0)  {<br>     printk(KERN_ERR "DMA timed out\n");</span></div><div><span style="font-family:monospace">}</span></div><div><span style="font-family:monospace">else { ... }<br></span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">======</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">I cannot figure out what to do in the case of a timeout. It appears descriptors (chan_desc) are being leaked when completion cannot be completed. I see some patches to make the list of descriptors larger but it appears the default/configured is 255. So if I sit and timeout for 3sec * 255, I run out of descriptors and that DMA engine instance is no longer usable.</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">It appears that even Xilinx's AXIDMA Test driver doesn't handle any sort of resource release or cleanup either:<br><a href="https://github.com/Xilinx/linux-xlnx/blob/master/drivers/dma/xilinx/axidmatest.c#L432">https://github.com/Xilinx/linux-xlnx/blob/master/drivers/dma/xilinx/axidmatest.c#L432</a><br><br></span></div><div><span style="font-family:monospace">I hope someone can point me in the right direction so I can timeout nicely.<br></span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">Thanks!</span><br></div><div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><font face="monospace, monospace">Anthony G. Clark</font></div><div dir="ltr"><font face="monospace, monospace"><br></font><div><font face="monospace, monospace">Gtalk :: clark.anthony.g </font></div><div><font face="monospace, monospace">Phone :: 951 526 5237 </font></div><div><br></div></div></div></div></div></div></div>