spi: rtk-nor: Limit exec_op writes to one byte per operation
Subsystems (2)
PATCH 1/1 spi: rtk-nor: Limit exec_op writes to one byte per operation
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.
--- drivers/spi/spi-rtk-nor.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/spi/spi-rtk-nor.c +13 -0
@@ -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)
Signature · 1 line
2.55.0
Mark Brown
maintainerQuoted 1 line · David Carlier
spi: rtk-nor: Limit
exec_opwrites 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