提交 e4d8817c 编写于 作者: P Peter Ujfalusi 提交者: Vinod Koul

dmaengine: edma: Fetch echan->edesc while holding lock in edma_comletion_handler

In order to avoid possible race condition when client drivers are using
dmaengine_terminate_sync() call to disable the channel.
Signed-off-by: NPeter Ujfalusi <peter.ujfalusi@ti.com>
Suggested-by: NLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: NVinod Koul <vinod.koul@intel.com>
上级 b84730ff
...@@ -1369,36 +1369,36 @@ static struct dma_async_tx_descriptor *edma_prep_dma_cyclic( ...@@ -1369,36 +1369,36 @@ static struct dma_async_tx_descriptor *edma_prep_dma_cyclic(
static void edma_completion_handler(struct edma_chan *echan) static void edma_completion_handler(struct edma_chan *echan)
{ {
struct device *dev = echan->vchan.chan.device->dev; struct device *dev = echan->vchan.chan.device->dev;
struct edma_desc *edesc = echan->edesc; struct edma_desc *edesc;
if (!edesc)
return;
spin_lock(&echan->vchan.lock); spin_lock(&echan->vchan.lock);
if (edesc->cyclic) { edesc = echan->edesc;
vchan_cyclic_callback(&edesc->vdesc); if (edesc) {
spin_unlock(&echan->vchan.lock); if (edesc->cyclic) {
return; vchan_cyclic_callback(&edesc->vdesc);
} else if (edesc->processed == edesc->pset_nr) { spin_unlock(&echan->vchan.lock);
edesc->residue = 0; return;
edma_stop(echan); } else if (edesc->processed == edesc->pset_nr) {
vchan_cookie_complete(&edesc->vdesc); edesc->residue = 0;
echan->edesc = NULL; edma_stop(echan);
vchan_cookie_complete(&edesc->vdesc);
dev_dbg(dev, "Transfer completed on channel %d\n", echan->edesc = NULL;
echan->ch_num);
} else { dev_dbg(dev, "Transfer completed on channel %d\n",
dev_dbg(dev, "Sub transfer completed on channel %d\n", echan->ch_num);
echan->ch_num); } else {
dev_dbg(dev, "Sub transfer completed on channel %d\n",
edma_pause(echan); echan->ch_num);
/* Update statistics for tx_status */ edma_pause(echan);
edesc->residue -= edesc->sg_len;
edesc->residue_stat = edesc->residue; /* Update statistics for tx_status */
edesc->processed_stat = edesc->processed; edesc->residue -= edesc->sg_len;
edesc->residue_stat = edesc->residue;
edesc->processed_stat = edesc->processed;
}
edma_execute(echan);
} }
edma_execute(echan);
spin_unlock(&echan->vchan.lock); spin_unlock(&echan->vchan.lock);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册