[PATCH v2 1/2] spi: spi-mem: Protect dirmap_create() with spi_mem_access_start/end
Paul Menzel
pmenzel at molgen.mpg.de
Sat Jan 17 15:46:57 PST 2026
Dear Chin-Ting,
Thank you for your patch.
Am 17.01.26 um 14:42 schrieb Chin-Ting Kuo:
> spi_mem_dirmap_create() may reconfigure controller-wide settings,
> which can interfere with concurrent transfers to other devices
> sharing the same SPI controller but using different chip selects.
>
> Wrap the ->dirmap_create() callback with spi_mem_access_start() and
> spi_mem_access_end() to serialize access and prevent cross-CS
> interference during dirmap creation.
Do you have a reproducer for this issue to test your patch? If yes, it’d
be great, if you documented it.
> Signed-off-by: Chin-Ting Kuo <chin-ting_kuo at aspeedtech.com>
> ---
> drivers/spi/spi-mem.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
> index c8b2add2640e..85702a77b3c8 100644
> --- a/drivers/spi/spi-mem.c
> +++ b/drivers/spi/spi-mem.c
> @@ -708,9 +708,18 @@ spi_mem_dirmap_create(struct spi_mem *mem,
>
> desc->mem = mem;
> desc->info = *info;
> - if (ctlr->mem_ops && ctlr->mem_ops->dirmap_create)
> + if (ctlr->mem_ops && ctlr->mem_ops->dirmap_create) {
> + ret = spi_mem_access_start(mem);
> + if (ret) {
> + kfree(desc);
> + return ERR_PTR(ret);
> + }
> +
> ret = ctlr->mem_ops->dirmap_create(desc);
>
> + spi_mem_access_end(mem);
> + }
> +
> if (ret) {
> desc->nodirmap = true;
> if (!spi_mem_supports_op(desc->mem, &desc->info.op_tmpl))
Reviewed-by: Paul Menzel <pmenzel at molgen.mpg.de>
Kind regards,
Paul
More information about the linux-arm-kernel
mailing list