From: sashiko-bot@kernel.org
To: ping.li <leeonion.muyu@gmail.com>,
miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH 1/3] mtd: rawnand: fsmc: declare NAND_USES_DMA
Date: Mon, 23 Nov 2026 06:01:52 +0000 [thread overview]
Message-ID: <sashiko-outbox-228750@kernel.org> (raw)
In-Reply-To: <20261123055020.1995251-2-ping.li@horizon.auto>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] mtd: rawnand: fsmc: unconditional NAND_USES_DMA on PIO-only
path
- [Low] mtd: rawnand: fsmc: inaccurate Fixes trailer citing mtdchar
commit
--
commit d8b98a2d7f37ac877e92b27587661c944ec57d7b
Author: Ping Li <leeonion.muyu@gmail.com>
> mtd: rawnand: fsmc: declare NAND_USES_DMA
>
> fsmc_exec_op() passes the data buffers provided by the NAND core
> straight to dma_map_single() when the controller runs in DMA mode,
> but the driver never declares NAND_USES_DMA. Because of this,
> nand_base cannot know the controller DMAs these buffers and never
> bounces non-linear-map ones (see the use_bounce_buf logic in
> nand_do_read_ops()/nand_do_write_ops()).
>
> Since the mtdchar MEMREAD/MEMWRITE ioctls allocate their buffers
> with kvmalloc(), a heavily fragmented system can already feed a
> vmalloc'd buffer into fsmc's DMA engine, which is not a valid
> dma_map_single() input.
>
> Declare NAND_USES_DMA so that nand_base bounces non-linear-map
> buffers through chip->data_buf, as the other DMA-capable
> controllers (arasan, denali, meson, mtk, nuvoton...) already do.
>
> Fixes: 83208e106a8e8 ("mtdchar: use kvmalloc() for potentially large allocations")
> Signed-off-by: Ping Li <leeonion.muyu@gmail.com>
[Severity: Low]
Does the Fixes: tag point to the right commit? 83208e106a8e ("mtdchar:
use kvmalloc() for potentially large allocations") only changed
mtdchar_write_ioctl(), whereas upper MTD layers such as UBIFS and JFFS2
passed vmalloc buffers long before that; DMA support in this driver came
from 4774fb0a48aa ("mtd: nand/fsmc: Add DMA support") and bounce buffer
support in nand_base came from 66507c7bc889 ("mtd: nand: Add support to
use nand_base poi databuf as bounce buffer").
> diff --git a/drivers/mtd/nand/raw/fsmc_nand.c b/drivers/mtd/nand/raw/fsmc_nand.c
> index eee00c6f43e07..2c3da9242a14b 100644
> --- a/drivers/mtd/nand/raw/fsmc_nand.c
> +++ b/drivers/mtd/nand/raw/fsmc_nand.c
> @@ -871,7 +871,7 @@ static int fsmc_nand_probe_config_dt(struct platform_device *pdev,
> u32 val;
> int ret;
>
> - nand->options = 0;
> + nand->options = NAND_USES_DMA;
[Severity: Medium]
Should nand->options set NAND_USES_DMA unconditionally when the driver
never runs in DMA mode?
In fsmc_nand_probe(), host is zero-allocated via devm_kzalloc_obj(),
leaving host->mode at 0, and ever since a1b1e1d5bdfe ("mtd: nand: fsmc:
finally remove fsmc_nand_platform_data") nothing in the driver ever sets
host->mode to USE_DMA_ACCESS (1). As a result, fsmc_exec_op() always
takes the MMIO PIO path (fsmc_read_buf() and fsmc_write_buf()), and
setting NAND_USES_DMA forces nand_do_read_ops() and nand_do_write_ops()
to bounce every vmalloc or kvmalloc buffer through chip->data_buf via an
unnecessary full-page copy.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123055020.1995251-1-ping.li@horizon.auto?part=1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2026-11-23 6:01 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 5:50 [PATCH 0/3] mtd: rawnand: protect DMA engines from vmalloc'd buffers ping.li
2026-11-23 5:50 ` ping.li
2026-11-23 5:50 ` [PATCH 1/3] mtd: rawnand: fsmc: declare NAND_USES_DMA ping.li
2026-11-23 5:50 ` ping.li
2026-11-23 6:01 ` sashiko-bot [this message]
2026-11-23 7:04 ` Ping Li
2026-11-23 7:04 ` Ping Li
2026-11-23 5:50 ` [PATCH 2/3] mtd: rawnand: intel: " ping.li
2026-11-23 5:50 ` ping.li
2026-11-23 6:01 ` sashiko-bot
2026-11-23 5:50 ` [PATCH 3/3] mtd: rawnand: r852: bounce non-linear-map buffers ping.li
2026-11-23 5:50 ` ping.li
2026-11-23 7:04 ` [PATCH v2 0/3] mtd: rawnand: protect DMA engines from vmalloc'd buffers Ping Li
2026-11-23 7:04 ` Ping Li
2026-11-23 7:04 ` [PATCH v2 1/3] mtd: rawnand: intel: declare NAND_USES_DMA Ping Li
2026-11-23 7:04 ` Ping Li
2026-11-23 7:04 ` [PATCH v2 2/3] mtd: rawnand: intel: unmap the DMA buffer in ebu_dma_start() Ping Li
2026-11-23 7:04 ` Ping Li
2026-11-23 7:04 ` [PATCH v2 3/3] mtd: rawnand: r852: bounce non-linear-map buffers Ping Li
2026-11-23 7:04 ` Ping Li
2026-11-25 8:55 ` Miquel Raynal
2026-11-25 8:55 ` Miquel Raynal
2026-11-25 9:25 ` Ping Li
2026-11-25 9:25 ` Ping Li
2026-11-25 9:25 ` [PATCH v3 0/3] mtd: rawnand: protect DMA engines from vmalloc'd buffers Ping Li
2026-11-25 9:25 ` Ping Li
2026-11-25 9:25 ` [PATCH v3 1/3] mtd: rawnand: intel: declare NAND_USES_DMA Ping Li
2026-11-25 9:25 ` Ping Li
2026-11-25 9:25 ` [PATCH v3 2/3] mtd: rawnand: intel: unmap the DMA buffer in ebu_dma_start() Ping Li
2026-11-25 9:25 ` Ping Li
2026-11-25 9:25 ` [PATCH v3 3/3] mtd: rawnand: r852: declare NAND_USES_DMA Ping Li
2026-11-25 9:25 ` Ping Li
2026-11-25 9:48 ` Miquel Raynal
2026-11-25 9:48 ` Miquel Raynal
2026-11-25 11:50 ` Ping Li
2026-11-25 11:50 ` Ping Li
2026-11-25 11:51 ` [PATCH v4 0/3] mtd: rawnand: protect DMA engines from vmalloc'd buffers Ping Li
2026-11-25 11:51 ` Ping Li
2026-11-25 11:51 ` [PATCH v4 1/3] mtd: rawnand: intel: declare NAND_USES_DMA Ping Li
2026-11-25 11:51 ` Ping Li
2026-11-25 11:51 ` [PATCH v4 2/3] mtd: rawnand: intel: unmap the DMA buffer in ebu_dma_start() Ping Li
2026-11-25 11:51 ` Ping Li
2026-11-25 11:51 ` [PATCH v4 3/3] mtd: rawnand: r852: declare NAND_USES_DMA Ping Li
2026-11-25 11:51 ` Ping Li
2026-11-25 12:10 ` sashiko-bot
2026-11-25 12:20 ` Miquel Raynal
2026-11-25 12:21 ` [PATCH v5 0/3] mtd: rawnand: protect DMA engines from vmalloc'd buffers Ping Li
2026-11-25 12:21 ` Ping Li
2026-11-25 12:21 ` [PATCH v5 1/3] mtd: rawnand: intel: declare NAND_USES_DMA Ping Li
2026-11-25 12:21 ` Ping Li
2026-11-25 12:21 ` [PATCH v5 2/3] mtd: rawnand: intel: unmap the DMA buffer in ebu_dma_start() Ping Li
2026-11-25 12:21 ` Ping Li
2026-11-25 12:21 ` [PATCH v5 3/3] mtd: rawnand: r852: declare NAND_USES_DMA Ping Li
2026-11-25 12:21 ` Ping Li
2026-11-25 12:55 ` Miquel Raynal
2026-11-25 12:55 ` Miquel Raynal
2026-11-26 6:02 ` Ping Li
2026-11-26 6:02 ` Ping Li
2026-11-26 11:03 ` Miquel Raynal
2026-11-26 11:03 ` Miquel Raynal
2026-11-26 11:24 ` Ping Li
2026-11-26 11:24 ` Ping Li
2026-11-26 13:28 ` Miquel Raynal
2026-11-26 13:28 ` Miquel Raynal
2026-11-27 2:04 ` Ping Li
2026-11-27 2:04 ` Ping Li
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-228750@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=leeonion.muyu@gmail.com \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--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.