drivers/dma/tegra186-gpc-dma.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tegra_dma_tx_status() reads tdc->status before taking tdc->vc.lock, and
tegra_dma_isr() snapshots tdc->dma_desc before taking the same lock. All
writers of these fields (tegra_dma_start(), tegra_dma_xfer_complete(),
tegra_dma_pause(), tegra_dma_resume() and tegra_dma_terminate_all()) update
them under tdc->vc.lock.
The unlocked read in tegra_dma_tx_status() can therefore report DMA_PAUSED
for a transfer that has already completed, and the unlocked read in
tegra_dma_isr() can pick up a tdc->dma_desc which is being cleared
concurrently, in which case the handler keeps using a stale descriptor
pointer.
Read both fields while holding tdc->vc.lock.
Fixes: ee17028 ("dmaengine: tegra: Add tegra gpcdma driver")
Signed-off-by: Ginger Li <ginger.jzllee@gmail.com>
---
drivers/dma/tegra186-gpc-dma.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/tegra186-gpc-dma.c b/drivers/dma/tegra186-gpc-dma.c
--- a/drivers/dma/tegra186-gpc-dma.c
+++ b/drivers/dma/tegra186-gpc-dma.c
@@ -606,7 +606,7 @@ static irqreturn_t tegra_dma_isr(int irq, void *dev_id
static irqreturn_t tegra_dma_isr(int irq, void *dev_id)
{
struct tegra_dma_channel *tdc = dev_id;
- struct tegra_dma_desc *dma_desc = tdc->dma_desc;
+ struct tegra_dma_desc *dma_desc;
struct tegra_dma_sg_req *sg_req;
u32 status;
@@ -619,6 +619,7 @@ static irqreturn_t tegra_dma_isr(int irq, void *dev_id
}
spin_lock(&tdc->vc.lock);
+ dma_desc = tdc->dma_desc;
status = tdc_read(tdc, tdc->regs->status);
if (!(status & TEGRA_GPCDMA_STATUS_ISE_EOC))
goto irq_done;
@@ -786,10 +787,10 @@ static enum dma_status tegra_dma_tx_status(struct dma_
if (ret == DMA_COMPLETE)
return ret;
+ spin_lock_irqsave(&tdc->vc.lock, flags);
if (tdc->status == DMA_PAUSED)
ret = DMA_PAUSED;
- spin_lock_irqsave(&tdc->vc.lock, flags);
vd = vchan_find_desc(&tdc->vc, cookie);
if (vd) {
dma_desc = vd_to_tegra_dma_desc(vd);
--
2.43.0
> Fixes: ee17028 ("dmaengine: tegra: Add tegra gpcdma driver")
Why did you specify a short hash for such a tag?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.3-rc4#n157
Regards,
Markus
© 2016 - 2026 Red Hat, Inc.