From: sashiko-bot@kernel.org
To: "Samarth Narang" <samarth.colleges@gmail.com>,
"Han Xu" <han.xu@nxp.com>,
"Miquel Raynal" <miquel.raynal@bootlin.com>,
"Vignesh Raghavendra" <vigneshr@ti.com>
Cc: "Richard Weinberger" <richard@nod.at>,
imx@lists.linux.dev, linux-mtd@lists.infradead.org,
Frank.Li@kernel.org
Subject: Re: [PATCH v2] mtd: rawnand: gpmi: terminate the DMA chain on completion timeout
Date: Fri, 30 Oct 2026 15:20:32 +0000 [thread overview]
Message-ID: <sashiko-outbox-191156@kernel.org> (raw)
In-Reply-To: <20261030150929.2944717-1-samarth.colleges@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] mtd: rawnand: gpmi: unsynchronized DMA termination in gpmi_nfc_exec_op()
--
commit f9aac792f98d50292f01d08b01dd1b06dcf84ac0
Author: Samarth Narang <samarth.colleges@gmail.com>
mtd: rawnand: gpmi: terminate the DMA chain on completion timeout
This commit calls dmaengine_terminate_sync() before unmapping DMA buffers
when a DMA completion timeout occurs in gpmi_nfc_exec_op(), intending to
stop the APBH DMA channel and prevent stale descriptors from running against
unmapped buffers.
> diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
> index 527165ccc839d..86163a552aad8 100644
> --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
> @@ -2659,6 +2659,7 @@ static int gpmi_nfc_exec_op(struct nand_chip *chip,
> if (!to) {
> dev_err(this->dev, "DMA timeout, last DMA\n");
> gpmi_dump_info(this);
> + dmaengine_terminate_sync(get_dma_chan(this));
[Severity: Medium]
Does dmaengine_terminate_sync() actually synchronize with the channel IRQ
and completion tasklet on mxs-dma?
In drivers/dma/mxs-dma.c, mxs_dma_probe() does not implement
device_synchronize, so dmaengine_synchronize() is a no-op, and
mxs_dma_terminate_all() resets the channel without killing mxs_chan->tasklet
or clearing mxs_chan->desc.callback:
drivers/dma/mxs-dma.c:mxs_dma_terminate_all() {
mxs_dma_reset_chan(chan);
mxs_dma_disable_chan(chan);
return 0;
}
Furthermore, when mxs_dma_reset_chan() resets an active APBH channel (or if
a late completion interrupt races with the timeout), mxs_dma_int_handler()
fires for the termination error (err == 0x01) or completion and schedules
mxs_chan->tasklet:
drivers/dma/mxs-dma.c:mxs_dma_int_handler() {
...
if (err) {
dev_dbg(mxs_dma->dma_device.dev,
"%s: error in channel %d\n", __func__,
chan);
mxs_chan->status = DMA_ERROR;
mxs_dma_reset_chan(&mxs_chan->chan);
}
...
/* schedule tasklet on this channel */
tasklet_schedule(&mxs_chan->tasklet);
}
Because mxs_chan->tasklet is not synchronized before
dmaengine_terminate_sync() returns, could mxs_dma_tasklet() run
dma_irq_callback(this) and complete this->dma_done after a subsequent
gpmi_nfc_exec_op() call has already reinitialized this->dma_done and
submitted a new transfer, causing the new operation to complete prematurely
and unmap its buffers while DMA is still active?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261030150929.2944717-1-samarth.colleges@gmail.com?part=1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Samarth Narang" <samarth.colleges@gmail.com>,
"Han Xu" <han.xu@nxp.com>,
"Miquel Raynal" <miquel.raynal@bootlin.com>,
"Vignesh Raghavendra" <vigneshr@ti.com>
Cc: "Richard Weinberger" <richard@nod.at>,
imx@lists.linux.dev, linux-mtd@lists.infradead.org,
Frank.Li@kernel.org
Subject: Re: [PATCH v2] mtd: rawnand: gpmi: terminate the DMA chain on completion timeout
Date: Fri, 30 Oct 2026 15:20:32 +0000 [thread overview]
Message-ID: <sashiko-outbox-191156@kernel.org> (raw)
In-Reply-To: <20261030150929.2944717-1-samarth.colleges@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] mtd: rawnand: gpmi: unsynchronized DMA termination in gpmi_nfc_exec_op()
--
commit f9aac792f98d50292f01d08b01dd1b06dcf84ac0
Author: Samarth Narang <samarth.colleges@gmail.com>
mtd: rawnand: gpmi: terminate the DMA chain on completion timeout
This commit calls dmaengine_terminate_sync() before unmapping DMA buffers
when a DMA completion timeout occurs in gpmi_nfc_exec_op(), intending to
stop the APBH DMA channel and prevent stale descriptors from running against
unmapped buffers.
> diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
> index 527165ccc839d..86163a552aad8 100644
> --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
> @@ -2659,6 +2659,7 @@ static int gpmi_nfc_exec_op(struct nand_chip *chip,
> if (!to) {
> dev_err(this->dev, "DMA timeout, last DMA\n");
> gpmi_dump_info(this);
> + dmaengine_terminate_sync(get_dma_chan(this));
[Severity: Medium]
Does dmaengine_terminate_sync() actually synchronize with the channel IRQ
and completion tasklet on mxs-dma?
In drivers/dma/mxs-dma.c, mxs_dma_probe() does not implement
device_synchronize, so dmaengine_synchronize() is a no-op, and
mxs_dma_terminate_all() resets the channel without killing mxs_chan->tasklet
or clearing mxs_chan->desc.callback:
drivers/dma/mxs-dma.c:mxs_dma_terminate_all() {
mxs_dma_reset_chan(chan);
mxs_dma_disable_chan(chan);
return 0;
}
Furthermore, when mxs_dma_reset_chan() resets an active APBH channel (or if
a late completion interrupt races with the timeout), mxs_dma_int_handler()
fires for the termination error (err == 0x01) or completion and schedules
mxs_chan->tasklet:
drivers/dma/mxs-dma.c:mxs_dma_int_handler() {
...
if (err) {
dev_dbg(mxs_dma->dma_device.dev,
"%s: error in channel %d\n", __func__,
chan);
mxs_chan->status = DMA_ERROR;
mxs_dma_reset_chan(&mxs_chan->chan);
}
...
/* schedule tasklet on this channel */
tasklet_schedule(&mxs_chan->tasklet);
}
Because mxs_chan->tasklet is not synchronized before
dmaengine_terminate_sync() returns, could mxs_dma_tasklet() run
dma_irq_callback(this) and complete this->dma_done after a subsequent
gpmi_nfc_exec_op() call has already reinitialized this->dma_done and
submitted a new transfer, causing the new operation to complete prematurely
and unmap its buffers while DMA is still active?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261030150929.2944717-1-samarth.colleges@gmail.com?part=1
next prev parent reply other threads:[~2026-10-30 15:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 15:09 [PATCH v2] mtd: rawnand: gpmi: terminate the DMA chain on completion timeout Samarth Narang
2026-10-30 15:09 ` Samarth Narang
2026-10-30 15:20 ` sashiko-bot [this message]
2026-10-30 15:20 ` 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=sashiko-outbox-191156@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=han.xu@nxp.com \
--cc=imx@lists.linux.dev \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=samarth.colleges@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vigneshr@ti.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.