Merge tag 'armsoc-cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
[deliverable/linux.git] / drivers / dma / edma.c
index 8181ed1313865015a169b1e19e44de5ad3df8eb5..3d277fa76c1abb7397071ef58350a091e943ba4a 100644 (file)
@@ -239,6 +239,9 @@ struct edma_cc {
        bool                            chmap_exist;
        enum dma_event_q                default_queue;
 
+       unsigned int                    ccint;
+       unsigned int                    ccerrint;
+
        /*
         * The slot_inuse bit for each PaRAM slot is clear unless the slot is
         * in use by Linux or if it is allocated to be used by DSP.
@@ -1069,10 +1072,8 @@ static struct dma_async_tx_descriptor *edma_prep_slave_sg(
 
        edesc = kzalloc(sizeof(*edesc) + sg_len * sizeof(edesc->pset[0]),
                        GFP_ATOMIC);
-       if (!edesc) {
-               dev_err(dev, "%s: Failed to allocate a descriptor\n", __func__);
+       if (!edesc)
                return NULL;
-       }
 
        edesc->pset_nr = sg_len;
        edesc->residue = 0;
@@ -1114,14 +1115,17 @@ static struct dma_async_tx_descriptor *edma_prep_slave_sg(
                edesc->absync = ret;
                edesc->residue += sg_dma_len(sg);
 
-               /* If this is the last in a current SG set of transactions,
-                  enable interrupts so that next set is processed */
-               if (!((i+1) % MAX_NR_SG))
-                       edesc->pset[i].param.opt |= TCINTEN;
-
-               /* If this is the last set, enable completion interrupt flag */
                if (i == sg_len - 1)
+                       /* Enable completion interrupt */
                        edesc->pset[i].param.opt |= TCINTEN;
+               else if (!((i+1) % MAX_NR_SG))
+                       /*
+                        * Enable early completion interrupt for the
+                        * intermediateset. In this case the driver will be
+                        * notified when the paRAM set is submitted to TC. This
+                        * will allow more time to set up the next set of slots.
+                        */
+                       edesc->pset[i].param.opt |= (TCINTEN | TCCMODE);
        }
        edesc->residue_stat = edesc->residue;
 
@@ -1173,10 +1177,8 @@ static struct dma_async_tx_descriptor *edma_prep_dma_memcpy(
 
        edesc = kzalloc(sizeof(*edesc) + nslots * sizeof(edesc->pset[0]),
                        GFP_ATOMIC);
-       if (!edesc) {
-               dev_dbg(dev, "Failed to allocate a descriptor\n");
+       if (!edesc)
                return NULL;
-       }
 
        edesc->pset_nr = nslots;
        edesc->residue = edesc->residue_stat = len;
@@ -1298,10 +1300,8 @@ static struct dma_async_tx_descriptor *edma_prep_dma_cyclic(
 
        edesc = kzalloc(sizeof(*edesc) + nslots * sizeof(edesc->pset[0]),
                        GFP_ATOMIC);
-       if (!edesc) {
-               dev_err(dev, "%s: Failed to allocate a descriptor\n", __func__);
+       if (!edesc)
                return NULL;
-       }
 
        edesc->cyclic = 1;
        edesc->pset_nr = nslots;
@@ -2207,10 +2207,8 @@ static int edma_probe(struct platform_device *pdev)
                return ret;
 
        ecc = devm_kzalloc(dev, sizeof(*ecc), GFP_KERNEL);
-       if (!ecc) {
-               dev_err(dev, "Can't allocate controller\n");
+       if (!ecc)
                return -ENOMEM;
-       }
 
        ecc->dev = dev;
        ecc->id = pdev->id;
@@ -2288,6 +2286,7 @@ static int edma_probe(struct platform_device *pdev)
                        dev_err(dev, "CCINT (%d) failed --> %d\n", irq, ret);
                        return ret;
                }
+               ecc->ccint = irq;
        }
 
        irq = platform_get_irq_byname(pdev, "edma3_ccerrint");
@@ -2303,6 +2302,7 @@ static int edma_probe(struct platform_device *pdev)
                        dev_err(dev, "CCERRINT (%d) failed --> %d\n", irq, ret);
                        return ret;
                }
+               ecc->ccerrint = irq;
        }
 
        ecc->dummy_slot = edma_alloc_slot(ecc, EDMA_SLOT_ANY);
@@ -2393,11 +2393,27 @@ err_reg1:
        return ret;
 }
 
+static void edma_cleanupp_vchan(struct dma_device *dmadev)
+{
+       struct edma_chan *echan, *_echan;
+
+       list_for_each_entry_safe(echan, _echan,
+                       &dmadev->channels, vchan.chan.device_node) {
+               list_del(&echan->vchan.chan.device_node);
+               tasklet_kill(&echan->vchan.task);
+       }
+}
+
 static int edma_remove(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct edma_cc *ecc = dev_get_drvdata(dev);
 
+       devm_free_irq(dev, ecc->ccint, ecc);
+       devm_free_irq(dev, ecc->ccerrint, ecc);
+
+       edma_cleanupp_vchan(&ecc->dma_slave);
+
        if (dev->of_node)
                of_dma_controller_free(dev->of_node);
        dma_async_device_unregister(&ecc->dma_slave);
This page took 0.031851 seconds and 5 git commands to generate.