]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
dma: mxs-dma: make mxs_dma_prep_slave_sg() multi user safe
authorLothar Waßmann <LW@KARO-electronics.de>
Thu, 8 Dec 2011 08:15:43 +0000 (09:15 +0100)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:33:52 +0000 (08:33 +0200)
Using a static variable for counting the number of CCWs attached to
a DMA channel when appending a new descriptor is not multi user safe.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
drivers/dma/mxs-dma.c

index 365e7ac569e96d8e71849bd419d3c2931e0093ad..afa53d53ae8c2b4f07acf88bd0f1a26392c3e6d3 100644 (file)
@@ -111,6 +111,7 @@ struct mxs_dma_chan {
        int                             chan_irq;
        struct mxs_dma_ccw              *ccw;
        dma_addr_t                      ccw_phys;
+       int                             desc_count;
        dma_cookie_t                    last_completed;
        enum dma_status                 status;
        unsigned int                    flags;
@@ -386,7 +387,7 @@ static struct dma_async_tx_descriptor *mxs_dma_prep_slave_sg(
        struct scatterlist *sg;
        int i, j;
        u32 *pio;
-       static int idx;
+       int idx = append ? mxs_chan->desc_count : 0;
 
        if (mxs_chan->status == DMA_IN_PROGRESS && !append)
                return NULL;
@@ -462,6 +463,7 @@ static struct dma_async_tx_descriptor *mxs_dma_prep_slave_sg(
                        }
                }
        }
+       mxs_chan->desc_count = idx;
 
        return &mxs_chan->desc;
 
@@ -523,6 +525,7 @@ static struct dma_async_tx_descriptor *mxs_dma_prep_dma_cyclic(
 
                i++;
        }
+       mxs_chan->desc_count = i;
 
        return &mxs_chan->desc;