[PATCH v3 3/3] mtd: rawnand: r852: declare NAND_USES_DMA

Ping Li leeonion.muyu at gmail.com
Wed Nov 25 01:25:38 PST 2026


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, as the other DMA-capable
controllers do.  The existing local bounce in r852_do_dma() is
still needed for the hardware's 512-byte alignment requirement,
which the core condition (chip->buf_align, default 1) does not
cover.

Fixes: 67e054e919248 ("mtd: nand: Add driver for Ricoh xD/SmartMedia reader")
Cc: stable at vger.kernel.org
Signed-off-by: Ping Li <leeonion.muyu at gmail.com>
---
 drivers/mtd/nand/raw/r852.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/mtd/nand/raw/r852.c b/drivers/mtd/nand/raw/r852.c
index 92c47d351c27..f930e8cc80e6 100644
--- a/drivers/mtd/nand/raw/r852.c
+++ b/drivers/mtd/nand/raw/r852.c
@@ -640,6 +640,16 @@ static int r852_register_nand_device(struct r852_device *dev)
 	if (dev->readonly)
 		dev->chip->options |= NAND_ROM;
 
+	/*
+	 * r852_do_dma() feeds the buffers provided by the NAND core
+	 * straight to dma_map_single(), so ask nand_base to bounce
+	 * non-linear-map buffers.  The local bounce in r852_do_dma()
+	 * is still needed for the hardware's 512-byte alignment
+	 * requirement, which the core condition (chip->buf_align,
+	 * default 1) does not cover.
+	 */
+	dev->chip->options |= NAND_USES_DMA;
+
 	r852_engine_enable(dev);
 
 	if (sm_register_device(mtd, dev->sm))
-- 
2.34.1




More information about the linux-mtd mailing list