From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Ping Li <leeonion.muyu@gmail.com>
Cc: richard@nod.at, vigneshr@ti.com, linux-mtd@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/3] mtd: rawnand: r852: bounce non-linear-map buffers
Date: Wed, 25 Nov 2026 09:55:13 +0100 [thread overview]
Message-ID: <875wxl1ea6.fsf@bootlin.com> (raw)
In-Reply-To: <20261123070440.3060882-4-leeonion.muyu@gmail.com> (Ping Li's message of "Mon, 23 Nov 2026 15:04:40 +0800")
On 23/11/2026 at 15:04:40 +08, Ping Li <leeonion.muyu@gmail.com> wrote:
> r852_do_dma() only bounces buffers that are not R852_DMA_LEN
> aligned. An aligned vmalloc'd buffer passes this check and gets
> fed to dma_map_single(), which is only valid for linear-map
> addresses. Such buffers are not hypothetical: mtdblock's write
> cache is vmalloc'ed, and UBIFS passes vmalloc'ed LPT buffers.
>
> Extend the bounce condition with a virt_addr_valid() check so
> that non-linear-map buffers go through the existing internal
> bounce buffer instead.
>
> Fixes: 67e054e919248 ("mtd: nand: Add driver for Ricoh xD/SmartMedia reader")
> Signed-off-by: Ping Li <leeonion.muyu@gmail.com>
> ---
> drivers/mtd/nand/raw/r852.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/r852.c b/drivers/mtd/nand/raw/r852.c
> index 92c47d351c27..4dbfc053fb21 100644
> --- a/drivers/mtd/nand/raw/r852.c
> +++ b/drivers/mtd/nand/raw/r852.c
> @@ -188,8 +188,8 @@ static void r852_do_dma(struct r852_device *dev, uint8_t *buf, int do_read)
> from device, for writes first fill the buffer from memory*/
> dev->dma_state = do_read ? DMA_INTERNAL : DMA_MEMORY;
>
> - /* if incoming buffer is not page aligned, we should do bounce */
> - if ((unsigned long)buf & (R852_DMA_LEN-1))
> + /* if incoming buffer is not usable for DMA, we should do bounce */
> + if (!virt_addr_valid(buf) || (unsigned long)buf & (R852_DMA_LEN
> - 1))
Why do we need a local bounce if the core can do it with NAND_USES_DMA?
Also please add Cc: stable to these three patches.
Thanks,
Miquèl
WARNING: multiple messages have this Message-ID (diff)
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Ping Li <leeonion.muyu@gmail.com>
Cc: richard@nod.at, vigneshr@ti.com, linux-mtd@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/3] mtd: rawnand: r852: bounce non-linear-map buffers
Date: Wed, 25 Nov 2026 09:55:13 +0100 [thread overview]
Message-ID: <875wxl1ea6.fsf@bootlin.com> (raw)
In-Reply-To: <20261123070440.3060882-4-leeonion.muyu@gmail.com> (Ping Li's message of "Mon, 23 Nov 2026 15:04:40 +0800")
On 23/11/2026 at 15:04:40 +08, Ping Li <leeonion.muyu@gmail.com> wrote:
> r852_do_dma() only bounces buffers that are not R852_DMA_LEN
> aligned. An aligned vmalloc'd buffer passes this check and gets
> fed to dma_map_single(), which is only valid for linear-map
> addresses. Such buffers are not hypothetical: mtdblock's write
> cache is vmalloc'ed, and UBIFS passes vmalloc'ed LPT buffers.
>
> Extend the bounce condition with a virt_addr_valid() check so
> that non-linear-map buffers go through the existing internal
> bounce buffer instead.
>
> Fixes: 67e054e919248 ("mtd: nand: Add driver for Ricoh xD/SmartMedia reader")
> Signed-off-by: Ping Li <leeonion.muyu@gmail.com>
> ---
> drivers/mtd/nand/raw/r852.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/r852.c b/drivers/mtd/nand/raw/r852.c
> index 92c47d351c27..4dbfc053fb21 100644
> --- a/drivers/mtd/nand/raw/r852.c
> +++ b/drivers/mtd/nand/raw/r852.c
> @@ -188,8 +188,8 @@ static void r852_do_dma(struct r852_device *dev, uint8_t *buf, int do_read)
> from device, for writes first fill the buffer from memory*/
> dev->dma_state = do_read ? DMA_INTERNAL : DMA_MEMORY;
>
> - /* if incoming buffer is not page aligned, we should do bounce */
> - if ((unsigned long)buf & (R852_DMA_LEN-1))
> + /* if incoming buffer is not usable for DMA, we should do bounce */
> + if (!virt_addr_valid(buf) || (unsigned long)buf & (R852_DMA_LEN
> - 1))
Why do we need a local bounce if the core can do it with NAND_USES_DMA?
Also please add Cc: stable to these three patches.
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2026-11-25 8:55 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
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 [this message]
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=875wxl1ea6.fsf@bootlin.com \
--to=miquel.raynal@bootlin.com \
--cc=leeonion.muyu@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--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.