* [PATCH] spi: rtk-nor: Limit exec_op writes to one byte per operation
@ 2026-10-30 14:59 David Carlier
2026-11-02 0:01 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: David Carlier @ 2026-10-30 14:59 UTC (permalink / raw)
To: Jyan Chou, Yu-Chun Lin
Cc: Mark Brown, linux-spi, linux-kernel, David Carlier, Sashiko
rtk_spi_do_write_and_cmds() issues a single writeb() to the data window,
so only the first byte of an addressed write reaches the flash, yet
exec_op reports success for the whole buffer. spi-nor hits this when
writing without a dirmap descriptor, e.g. for OTP security registers.
Such ops cannot be rejected in supports_op, since spi-nor probes page
program support with an addressed two byte write. Clamp them to one byte
in adjust_op_size instead, so spi-nor loops over the buffer.
Fixes: aca8cbecdd2e ("spi: spi-mem: Add Realtek SPI NOR flash controller driver")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/all/20260930071125.529791F000FF@smtp.kernel.org/
Signed-off-by: David Carlier <devnexen@gmail.com>
---
drivers/spi/spi-rtk-nor.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/spi/spi-rtk-nor.c b/drivers/spi/spi-rtk-nor.c
index 75856c31d2e6..55ea7c371854 100644
--- a/drivers/spi/spi-rtk-nor.c
+++ b/drivers/spi/spi-rtk-nor.c
@@ -357,6 +357,18 @@ static bool rtk_spi_supports_op(struct spi_mem *mem,
return spi_mem_default_supports_op(mem, op);
}
+static int rtk_spi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
+{
+ /*
+ * A write through exec_op is a single access to the data window,
+ * which programs one byte. Let the caller split longer writes.
+ */
+ if (op->data.dir == SPI_MEM_DATA_OUT && op->addr.nbytes)
+ op->data.nbytes = min(op->data.nbytes, 1U);
+
+ return 0;
+}
+
static int rtk_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
{
const struct spi_mem_op *op = desc->info.op_tmpl;
@@ -449,6 +461,7 @@ static const struct spi_controller_mem_ops rtk_spi_mem_ops = {
.dirmap_create = rtk_spi_dirmap_create,
.dirmap_read = rtk_spi_dirmap_read,
.dirmap_write = rtk_spi_dirmap_write,
+ .adjust_op_size = rtk_spi_adjust_op_size,
};
static int rtk_spi_probe(struct platform_device *pdev)
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] spi: rtk-nor: Limit exec_op writes to one byte per operation
2026-10-30 14:59 [PATCH] spi: rtk-nor: Limit exec_op writes to one byte per operation David Carlier
@ 2026-11-02 0:01 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2026-11-02 0:01 UTC (permalink / raw)
To: Jyan Chou, Yu-Chun Lin, David Carlier; +Cc: linux-spi, linux-kernel, Sashiko
On Fri, 30 Oct 2026 14:59:06 +0000, David Carlier wrote:
> spi: rtk-nor: Limit exec_op writes to one byte per operation
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.4
Thanks!
[1/1] spi: rtk-nor: Limit exec_op writes to one byte per operation
https://git.kernel.org/broonie/spi/c/30421d2469d3
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-02 12:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-30 14:59 [PATCH] spi: rtk-nor: Limit exec_op writes to one byte per operation David Carlier
2026-11-02 0:01 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox