* [PATCH] dmaengine: tegra186-gpc-dma: Read channel state under the lock
@ 2026-09-22 7:22 Ginger Li
2026-09-23 19:44 ` Markus Elfring
0 siblings, 1 reply; 2+ messages in thread
From: Ginger Li @ 2026-09-22 7:22 UTC (permalink / raw)
To: ldewangan, jonathanh, vkoul; +Cc: dmaengine, linux-tegra, linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] dmaengine: tegra186-gpc-dma: Read channel state under the lock
2026-09-22 7:22 [PATCH] dmaengine: tegra186-gpc-dma: Read channel state under the lock Ginger Li
@ 2026-09-23 19:44 ` Markus Elfring
0 siblings, 0 replies; 2+ messages in thread
From: Markus Elfring @ 2026-09-23 19:44 UTC (permalink / raw)
To: Ginger Li, dmaengine, linux-tegra
Cc: LKML, Jonathan Hunter, Laxman Dewangan, Vinod Koul
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-23 19:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-22 7:22 [PATCH] dmaengine: tegra186-gpc-dma: Read channel state under the lock Ginger Li
2026-09-23 19:44 ` Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®