]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
dmaengine: pxa_dma: fix residue corner case
authorRobert Jarzmik <robert.jarzmik@free.fr>
Wed, 30 Sep 2015 17:42:15 +0000 (19:42 +0200)
committerVinod Koul <vinod.koul@intel.com>
Thu, 1 Oct 2015 02:14:31 +0000 (07:44 +0530)
A very tiny temporal window exists in the residue calculation where :
 - upon entering residue calculation, the transfer is ongoing
 - when reading the current transfer pointer, it just changed to
   the "finisher/linker" descriptor

In this case, the residue returned is the whole transfer length instead
of 0. Fix it.

This appears almost in one extreme case, where the driver is used
by older clients which inquire for residue in interrupt context, such
as the smsc91x ethernet driver, in a tight loop :
  interrupt_handler()
    dmaengine_submit()
    do {
      dmaengine_tx_status()
    } while (residue > 0 || status != DMA_ERROR)

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
drivers/dma/pxa_dma.c

index 064a8266a3b727ba8b28ab33adc5dadf9dd6499a..fc4156afa070306cd2fee4502f361717f364706b 100644 (file)
@@ -1186,6 +1186,16 @@ static unsigned int pxad_residue(struct pxad_chan *chan,
        else
                curr = phy_readl_relaxed(chan->phy, DTADR);
 
+       /*
+        * curr has to be actually read before checking descriptor
+        * completion, so that a curr inside a status updater
+        * descriptor implies the following test returns true, and
+        * preventing reordering of curr load and the test.
+        */
+       rmb();
+       if (is_desc_completed(vd))
+               goto out;
+
        for (i = 0; i < sw_desc->nb_desc - 1; i++) {
                hw_desc = sw_desc->hw_desc[i];
                if (sw_desc->hw_desc[0]->dcmd & PXA_DCMD_INCSRCADDR)