All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ping Li" <leeonion.muyu@gmail.com>,
	miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com
Cc: tudor.ambarus@linaro.org, kyungmin.park@samsung.com,
	linux-mtd@lists.infradead.org
Subject: Re: [PATCH v3 4/4] mtd: onenand: samsung: accept vmalloc'd bounce buffers
Date: Fri, 04 Dec 2026 06:04:18 +0000	[thread overview]
Message-ID: <sashiko-outbox-249177@kernel.org> (raw)
In-Reply-To: <20261204054630.3443342-5-leeonion.muyu@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mtd: onenand: samsung: vmalloc buffers demote unaligned
  S5PC110 reads to PIO
--

commit 66ce872bce61be56a1aea4a1bc0e7bc0d241e303
Author: Ping Li <leeonion.muyu@gmail.com>

mtd: onenand: samsung: accept vmalloc'd bounce buffers

This commit sets mtd->allows_vmalloc_bufs to true in s3c_onenand_probe()
so mtdchar transfers can allocate vmalloc bounce buffers.

> diff --git a/drivers/mtd/nand/onenand/onenand_samsung.c b/drivers/mtd/nand/onenand/onenand_samsung.c
> index 8c2d3866a6d6d..a50009345b5cb 100644
> --- a/drivers/mtd/nand/onenand/onenand_samsung.c
> +++ b/drivers/mtd/nand/onenand/onenand_samsung.c
> @@ -931,6 +931,8 @@ static int s3c_onenand_probe(struct platform_device *pdev)
>  	if (s3c_read_reg(MEM_CFG_OFFSET) & ONENAND_SYS_CFG1_SYNC_READ)
>  		dev_info(&onenand->pdev->dev, "OneNAND Sync. Burst Read enabled\n");
>  
> +	mtd->allows_vmalloc_bufs = true;

[Severity: Medium]
Does enabling allows_vmalloc_bufs demote unaligned S5PC110 reads from DMA
to CPU PIO?

Contrary to the commit message, s5pc110_read_bufferram() does not map a
cross-page vmalloc buffer page by page; it bails out to PIO memcpy_fromio()
whenever a single-page transfer crosses a PAGE_SIZE boundary:

drivers/mtd/nand/onenand/onenand_samsung.c:s5pc110_read_bufferram() {
	...
	if (buf >= high_memory) {
		struct page *page;

		if (((size_t) buf & PAGE_MASK) !=
		    ((size_t) (buf + count - 1) & PAGE_MASK))
			goto normal;
	...
}

With allows_vmalloc_bufs set, mtdchar_read() allocates via kvmalloc()
instead of halving contiguous kmalloc() allocations, so multi-page reads
fall back to vmalloc() readily under fragmentation because
kmalloc_gfp_adjust() strips __GFP_DIRECT_RECLAIM above PAGE_SIZE.

When reading from a 4-byte-aligned, non-writesize-aligned offset,
onenand_read_ops_nolock() advances buf by writesize - column after the
initial partial page, so 50% (2 KiB) to 100% (4 KiB) of later full-page
reads cross PAGE_SIZE and demote to PIO instead of using dma_map_single().

Even for aligned reads, falling directly to vmalloc() adds vmalloc PTE/TLB
overhead, per-page vmalloc_to_page() walks, and kmap_atomic_pfn() cache
maintenance in dma_cache_maint_page() on 32-bit ARM with CONFIG_HIGHMEM.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204054630.3443342-1-leeonion.muyu@gmail.com?part=4

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

      reply	other threads:[~2026-12-04  6:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  5:46 [PATCH v3 0/4] mtdchar: per-device bounce buffer policy Ping Li
2026-12-04  5:46 ` Ping Li
2026-12-04  5:46 ` [PATCH v3 1/4] mtd: core: add per-device bounce buffer allocation helper Ping Li
2026-12-04  5:46   ` Ping Li
2026-12-04  6:03   ` sashiko-bot
2026-12-04  5:46 ` [PATCH v3 2/4] mtd: mtdchar: use mtd_alloc_buf() for the read/write bounce buffers Ping Li
2026-12-04  5:46   ` Ping Li
2026-12-04  6:03   ` sashiko-bot
2026-12-04  5:46 ` [PATCH v3 3/4] mtd: hyperbus: accept vmalloc'd " Ping Li
2026-12-04  5:46   ` Ping Li
2026-12-04  6:04   ` sashiko-bot
2026-12-04  5:46 ` [PATCH v3 4/4] mtd: onenand: samsung: " Ping Li
2026-12-04  5:46   ` Ping Li
2026-12-04  6:04   ` sashiko-bot [this message]

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-249177@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kyungmin.park@samsung.com \
    --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=tudor.ambarus@linaro.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 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.