DMA Engine development
 help / color / mirror / Atom feed
From: Runyu Xiao <runyu.xiao@seu.edu.cn>
To: vkoul@kernel.org
Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, runyu.xiao@seu.edu.cn,
	jianhao.xu@seu.edu.cn
Subject: [PATCH] dmaengine: tegra: initialize channel state before requesting IRQ
Date: Sun, 30 Aug 2026 14:12:13 +0800	[thread overview]
Message-ID: <20260830061213.2209331-1-runyu.xiao@seu.edu.cn> (raw)

tegra_dma_probe() registers a channel IRQ before initializing the
channel lock, tasklet, waitqueue, and descriptor lists used by the
interrupt path. A pending interrupt can therefore access uninitialized
channel state.

Prepare the channel state before requesting its IRQ so the handler and
tasklet always see initialized synchronization and list objects.

Fixes: ec8a1586780c ("dma: tegra: add dmaengine based dma driver")
Cc: stable@vger.kernel.org
Assisted-by: Codex:GPT-5
Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
---
 drivers/dma/tegra20-apb-dma.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
index 640b8a218..23fd294ab 100644
--- a/drivers/dma/tegra20-apb-dma.c
+++ b/drivers/dma/tegra20-apb-dma.c
@@ -1494,6 +1494,19 @@ static int tegra_dma_probe(struct platform_device *pdev)
 		}
 
 		snprintf(tdc->name, sizeof(tdc->name), "apbdma.%d", i);
+		tdc->tdma = tdma;
+		tdc->id = i;
+		tdc->slave_id = TEGRA_APBDMA_SLAVE_ID_INVALID;
+
+		tasklet_setup(&tdc->tasklet, tegra_dma_tasklet);
+		spin_lock_init(&tdc->lock);
+		init_waitqueue_head(&tdc->wq);
+
+		INIT_LIST_HEAD(&tdc->pending_sg_req);
+		INIT_LIST_HEAD(&tdc->free_sg_req);
+		INIT_LIST_HEAD(&tdc->free_dma_desc);
+		INIT_LIST_HEAD(&tdc->cb_desc);
+
 		ret = devm_request_irq(&pdev->dev, irq, tegra_dma_isr, 0,
 				       tdc->name, tdc);
 		if (ret) {
@@ -1507,18 +1520,6 @@ static int tegra_dma_probe(struct platform_device *pdev)
 		dma_cookie_init(&tdc->dma_chan);
 		list_add_tail(&tdc->dma_chan.device_node,
 			      &tdma->dma_dev.channels);
-		tdc->tdma = tdma;
-		tdc->id = i;
-		tdc->slave_id = TEGRA_APBDMA_SLAVE_ID_INVALID;
-
-		tasklet_setup(&tdc->tasklet, tegra_dma_tasklet);
-		spin_lock_init(&tdc->lock);
-		init_waitqueue_head(&tdc->wq);
-
-		INIT_LIST_HEAD(&tdc->pending_sg_req);
-		INIT_LIST_HEAD(&tdc->free_sg_req);
-		INIT_LIST_HEAD(&tdc->free_dma_desc);
-		INIT_LIST_HEAD(&tdc->cb_desc);
 	}
 
 	dma_cap_set(DMA_SLAVE, tdma->dma_dev.cap_mask);
-- 
2.34.1

             reply	other threads:[~2026-08-30  6:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-30  6:12 Runyu Xiao [this message]
2026-08-30  6:25 ` [PATCH] dmaengine: tegra: initialize channel state before requesting IRQ sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260830061213.2209331-1-runyu.xiao@seu.edu.cn \
    --to=runyu.xiao@seu.edu.cn \
    --cc=dmaengine@vger.kernel.org \
    --cc=jianhao.xu@seu.edu.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox