|
@@ -934,49 +934,24 @@ EXPORT_SYMBOL(dma_async_tx_descriptor_init);
|
|
|
|
|
|
/* dma_wait_for_async_tx - spin wait for a transaction to complete
|
|
|
* @tx: in-flight transaction to wait on
|
|
|
- *
|
|
|
- * This routine assumes that tx was obtained from a call to async_memcpy,
|
|
|
- * async_xor, async_memset, etc which ensures that tx is "in-flight" (prepped
|
|
|
- * and submitted). Walking the parent chain is only meant to cover for DMA
|
|
|
- * drivers that do not implement the DMA_INTERRUPT capability and may race with
|
|
|
- * the driver's descriptor cleanup routine.
|
|
|
*/
|
|
|
enum dma_status
|
|
|
dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx)
|
|
|
{
|
|
|
- enum dma_status status;
|
|
|
- struct dma_async_tx_descriptor *iter;
|
|
|
- struct dma_async_tx_descriptor *parent;
|
|
|
+ unsigned long dma_sync_wait_timeout = jiffies + msecs_to_jiffies(5000);
|
|
|
|
|
|
if (!tx)
|
|
|
return DMA_SUCCESS;
|
|
|
|
|
|
- WARN_ONCE(tx->parent, "%s: speculatively walking dependency chain for"
|
|
|
- " %s\n", __func__, dma_chan_name(tx->chan));
|
|
|
-
|
|
|
- /* poll through the dependency chain, return when tx is complete */
|
|
|
- do {
|
|
|
- iter = tx;
|
|
|
-
|
|
|
- /* find the root of the unsubmitted dependency chain */
|
|
|
- do {
|
|
|
- parent = iter->parent;
|
|
|
- if (!parent)
|
|
|
- break;
|
|
|
- else
|
|
|
- iter = parent;
|
|
|
- } while (parent);
|
|
|
-
|
|
|
- /* there is a small window for ->parent == NULL and
|
|
|
- * ->cookie == -EBUSY
|
|
|
- */
|
|
|
- while (iter->cookie == -EBUSY)
|
|
|
- cpu_relax();
|
|
|
-
|
|
|
- status = dma_sync_wait(iter->chan, iter->cookie);
|
|
|
- } while (status == DMA_IN_PROGRESS || (iter != tx));
|
|
|
-
|
|
|
- return status;
|
|
|
+ while (tx->cookie == -EBUSY) {
|
|
|
+ if (time_after_eq(jiffies, dma_sync_wait_timeout)) {
|
|
|
+ pr_err("%s timeout waiting for descriptor submission\n",
|
|
|
+ __func__);
|
|
|
+ return DMA_ERROR;
|
|
|
+ }
|
|
|
+ cpu_relax();
|
|
|
+ }
|
|
|
+ return dma_sync_wait(tx->chan, tx->cookie);
|
|
|
}
|
|
|
EXPORT_SYMBOL_GPL(dma_wait_for_async_tx);
|
|
|
|