From: Miquel Raynal <miquel.raynal@bootlin.com>
To: fzz <1768315307@qq.com>
Cc: Vignesh Raghavendra <vigneshr@ti.com>,
Richard Weinberger <richard@nod.at>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mtd: spinand: cache the last read page to avoid redundant SPI operations
Date: Mon, 07 Sep 2026 14:33:24 +0200 [thread overview]
Message-ID: <87jyoxw8a3.fsf@bootlin.com> (raw)
In-Reply-To: <tencent_219EED44C45D6CEC1D6B6724343E13733005@qq.com> (fzz's message of "Mon, 7 Sep 2026 19:10:40 +0800")
Hello,
On 07/09/2026 at 19:10:40 +08, fzz <1768315307@qq.com> wrote:
> When squashfs reads files through mtdblock, the mtdblock layer
> splits I/O into 512-byte sectors. For a 4K-page SPI NAND, this
> means reading the same page 8 times (4096 / 512), generating 7x
> redundant SPI read-from-cache operations. Each such operation
> involves a full SPI bus transaction, significantly slowing down
> boot time and file access.
>
> Cache the last successfully read page in spinand_device to avoid
> these redundant operations. When the same {target, eraseblock,
> page} is requested consecutively, the data is served directly
> from the bounce buffer (databuf) via memcpy, skipping the SPI
> transaction entirely.
>
> The cache is invalidated on write and erase operations. RAW reads,
> OOB reads, and continuous reads are excluded from caching to
> maintain correctness.
Why would you use mtdblock on top of a SPI NAND? It sounds like a very
bad choice.
Maybe mtdblock itself could be improved to avoid 512B accesses instead?
> Signed-off-by: fzz <1768315307@qq.com>
Unfortunately, for licensing and copyright reasons, pseudonyms are not
allowed in the Linux kernel.
> ---
> drivers/mtd/nand/spi/core.c | 36 +++++++++++++++++++++++++++++++++++-
> include/linux/mtd/spinand.h | 9 +++++++++
> 2 files changed, 44 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
> index 8bf9301f25e7..fc082127bda8 100644
> --- a/drivers/mtd/nand/spi/core.c
> +++ b/drivers/mtd/nand/spi/core.c
> @@ -557,7 +557,14 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand,
> req->ooblen);
> else
> memcpy(req->oobbuf.in, spinand->oobbuf + req->ooboffs,
> - req->ooblen);
> + req->ooblen);
Spurious change.
> + }
> +
Thanks,
Miquèl
next prev parent reply other threads:[~2026-09-07 12:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 11:10 fzz
2026-09-07 12:33 ` Miquel Raynal [this message]
2026-09-08 3:34 ` 1768315307
2026-09-08 1:51 ` kernel test robot
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=87jyoxw8a3.fsf@bootlin.com \
--to=miquel.raynal@bootlin.com \
--cc=1768315307@qq.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®