From: Ping Li <leeonion.muyu@gmail.com>
To: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
Ping Li <leeonion.muyu@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH v5 3/3] mtd: rawnand: r852: declare NAND_USES_DMA
Date: Wed, 25 Nov 2026 20:21:35 +0800 [thread overview]
Message-ID: <20261125122135.44696-4-leeonion.muyu@gmail.com> (raw)
In-Reply-To: <20261125122135.44696-1-leeonion.muyu@gmail.com>
r852_do_dma() feeds the buffers provided by the NAND core straight
to dma_map_single(), which is only valid for linear-map addresses,
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. Such buffers are not hypothetical:
mtdblock's write cache is vmalloc'ed and UBIFS passes vmalloc'ed
LPT buffers.
Declare NAND_USES_DMA so that nand_base bounces non-linear-map
buffers through chip->data_buf, and advertise the hardware's
512-byte alignment requirement through chip->buf_align so that
misaligned linear buffers are bounced as well, like the other
DMA-capable controllers do. Both only apply when the controller
actually uses DMA: the PIO fallback path does not care about
buffer addresses being linear-map or 512-byte aligned.
Fixes: 67e054e919248 ("mtd: nand: Add driver for Ricoh xD/SmartMedia reader")
Cc: stable@vger.kernel.org
Signed-off-by: Ping Li <leeonion.muyu@gmail.com>
---
drivers/mtd/nand/raw/r852.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/mtd/nand/raw/r852.c b/drivers/mtd/nand/raw/r852.c
index 92c47d351c27..c5a3622cddf6 100644
--- a/drivers/mtd/nand/raw/r852.c
+++ b/drivers/mtd/nand/raw/r852.c
@@ -640,6 +640,11 @@ static int r852_register_nand_device(struct r852_device *dev)
if (dev->readonly)
dev->chip->options |= NAND_ROM;
+ if (dev->dma_usable) {
+ dev->chip->options |= NAND_USES_DMA;
+ dev->chip->buf_align = R852_DMA_LEN;
+ }
+
r852_engine_enable(dev);
if (sm_register_device(mtd, dev->sm))
--
2.34.1
next prev parent reply other threads:[~2026-11-25 12:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261123070440.3060882-1-leeonion.muyu@gmail.com>
[not found] ` <20261125092538.1938516-1-leeonion.muyu@gmail.com>
2026-11-25 9:25 ` [PATCH v3 1/3] mtd: rawnand: intel: declare NAND_USES_DMA 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 ` [PATCH v3 3/3] mtd: rawnand: r852: declare NAND_USES_DMA Ping Li
2026-11-25 9:48 ` Miquel Raynal
[not found] ` <20261125115108.4147741-1-leeonion.muyu@gmail.com>
2026-11-25 11:51 ` [PATCH v4 1/3] mtd: rawnand: intel: " 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 ` [PATCH v4 3/3] mtd: rawnand: r852: declare NAND_USES_DMA Ping Li
[not found] ` <20261125122135.44696-1-leeonion.muyu@gmail.com>
2026-11-25 12:21 ` [PATCH v5 1/3] mtd: rawnand: intel: " 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 [this message]
2026-11-25 12:55 ` [PATCH v5 3/3] mtd: rawnand: r852: declare NAND_USES_DMA Miquel Raynal
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=20261125122135.44696-4-leeonion.muyu@gmail.com \
--to=leeonion.muyu@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=stable@vger.kernel.org \
--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