ARM: tegra: Prevent requeuing in-progress DMA requests
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-tegra / dma.c
index 250bc7baa00a13f9166614c621ed433a8e481afd..4625e3ae766ec20e8ae938bbd941ad1aa22f8e9d 100644 (file)
@@ -311,6 +311,7 @@ int tegra_dma_enqueue_req(struct tegra_dma_channel *ch,
        struct tegra_dma_req *req)
 {
        unsigned long irq_flags;
+       struct tegra_dma_req *_req;
        int start_dma = 0;
 
        if (req->size > NV_DMA_MAX_TRASFER_SIZE ||
@@ -321,6 +322,13 @@ int tegra_dma_enqueue_req(struct tegra_dma_channel *ch,
 
        spin_lock_irqsave(&ch->lock, irq_flags);
 
+       list_for_each_entry(_req, &ch->list, node) {
+               if (req == _req) {
+                   spin_unlock_irqrestore(&ch->lock, irq_flags);
+                   return -EEXIST;
+               }
+       }
+
        req->bytes_transferred = 0;
        req->status = 0;
        req->buffer_status = 0;