Re: [PATCH v5 3/3] mtd: rawnand: r852: declare NAND_USES_DMA
From: Miquel Raynal
Date: Wed Nov 25 2026 - 07:55:57 EST
On 25/11/2026 at 20:21:35 +08, Ping Li <leeonion.muyu@xxxxxxxxx> wrote:
> 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@xxxxxxxxxxxxxxx
> Signed-off-by: Ping Li <leeonion.muyu@xxxxxxxxx>
> ---
> 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;
> + }
Wasn't in this driver a bounce buffering operation that is no longer needed?