From: sashiko-bot@kernel.org
To: "Samarth Narang" <samarth.colleges@gmail.com>,
"Miquel Raynal" <miquel.raynal@bootlin.com>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
"Han Xu" <han.xu@nxp.com>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
"Alexandre Torgue" <alexandre.torgue@foss.st.com>
Cc: "Richard Weinberger" <richard@nod.at>,
linux-mtd@lists.infradead.org, imx@lists.linux.dev,
linux-stm32@st-md-mailman.stormreply.com, Frank.Li@kernel.org
Subject: Re: [PATCH v2 5/6] mtd: rawnand: marvell: stop DMA before unmapping on timeout
Date: Fri, 30 Oct 2026 16:38:42 +0000 [thread overview]
Message-ID: <sashiko-outbox-191272@kernel.org> (raw)
In-Reply-To: <20261030162041.2998170-6-samarth.colleges@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] mtd: rawnand: marvell: sleep in atomic context in marvell_nfc_xfer_data_dma()
--
commit cbbe6eae8df4a34b02e625e64676a65024331f76
Author: Samarth Narang <samarth.colleges@gmail.com>
mtd: rawnand: marvell: stop DMA before unmapping on timeout
This commit replaces dmaengine_terminate_all() with
dmaengine_terminate_sync() and moves it before dma_unmap_sg() on the
timeout path in marvell_nfc_xfer_data_dma() so the DMA transfer is
stopped before unmapping the buffer.
> diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
> index 38b7eb5b992c8..a342a48e2a08c 100644
> --- a/drivers/mtd/nand/raw/marvell_nand.c
> +++ b/drivers/mtd/nand/raw/marvell_nand.c
> @@ -900,14 +900,15 @@ static int marvell_nfc_xfer_data_dma(struct marvell_nfc *nfc,
>
> dma_async_issue_pending(nfc->dma_chan);
> ret = marvell_nfc_wait_cmdd(nfc->selected_chip);
> - dma_unmap_sg(nfc->dma_chan->device->dev, &sg, 1, direction);
> - marvell_nfc_disable_dma(nfc);
> if (ret) {
> dev_err(nfc->dev, "Timeout waiting for DMA (status: %d)\n",
> dmaengine_tx_status(nfc->dma_chan, cookie, NULL));
> - dmaengine_terminate_all(nfc->dma_chan);
> - return -ETIMEDOUT;
> + dmaengine_terminate_sync(nfc->dma_chan);
[Severity: Medium]
Can calling dmaengine_terminate_sync() here sleep in atomic context during
a panic write?
This driver supports mtd->oops_panic_write by polling in
marvell_nfc_wait_op() instead of sleeping:
drivers/mtd/nand/raw/marvell_nand.c:marvell_nfc_wait_op() {
if (mtd->oops_panic_write) {
ret = marvell_nfc_poll_status(nfc, NDSR_RDY(0),
NDSR_RDY(0),
timeout_ms);
} else {
init_completion(&nfc->complete);
...
}
When nfc->use_dma is enabled on NFCv1, panic writes still go through
marvell_nfc_xfer_data_dma():
mtd_panic_write()
-> panic_nand_write()
-> nand_do_write_ops()
-> nand_write_page()
-> marvell_nfc_hw_ecc_hmg_write_page()
-> marvell_nfc_hw_ecc_hmg_do_write_page()
-> marvell_nfc_xfer_data_dma()
Because mtd_panic_write() can be invoked with interrupts disabled or under
a raw spinlock (such as pstore_dump()), and dmaengine_terminate_sync()
calls dmaengine_synchronize() (which calls might_sleep(), wait_event() in
pxad_synchronize(), and tasklet_kill() in vchan_synchronize()), wouldn't a
DMA timeout during a panic write trigger a sleep-in-atomic bug or hang
waiting for the DMA tasklet while softirqs are disabled?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261030162041.2998170-1-samarth.colleges@gmail.com?part=5
next prev parent reply other threads:[~2026-10-30 16:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 16:20 [PATCH v2 0/6] mtd: nand: stop DMA before unmapping on error and timeout paths Samarth Narang
2026-10-30 16:20 ` [PATCH v2 1/6] mtd: rawnand: gpmi: terminate the DMA chain on completion timeout Samarth Narang
2026-10-30 16:20 ` [PATCH v2 2/6] mtd: nand: qpic_common: terminate DMA channels on transfer timeout Samarth Narang
2026-10-30 16:20 ` [PATCH v2 3/6] mtd: rawnand: stm32_fmc2: retire data DMA before unmapping on errors Samarth Narang
2026-10-30 16:20 ` [PATCH v2 4/6] mtd: rawnand: omap2: terminate DMA when prefetch cannot be enabled Samarth Narang
2026-10-30 16:20 ` [PATCH v2 5/6] mtd: rawnand: marvell: stop DMA before unmapping on timeout Samarth Narang
2026-10-30 16:38 ` sashiko-bot [this message]
2026-10-30 16:20 ` [PATCH v2 6/6] mtd: rawnand: sh_flctl: use dmaengine_terminate_sync() on DMA timeout Samarth Narang
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-191272@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=alexandre.torgue@foss.st.com \
--cc=han.xu@nxp.com \
--cc=imx@lists.linux.dev \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mani@kernel.org \
--cc=mcoquelin.stm32@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox