[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<TYZPR06MB5203B67C187C52A47C0A29D5B28BA@TYZPR06MB5203.apcprd06.prod.outlook.com>
Date: Sun, 18 Jan 2026 12:38:43 +0000
From: Chin-Ting Kuo <chin-ting_kuo@...eedtech.com>
To: Paul Menzel <pmenzel@...gen.mpg.de>
CC: "clg@...d.org" <clg@...d.org>, "broonie@...nel.org" <broonie@...nel.org>,
"boris.brezillon@...tlin.com" <boris.brezillon@...tlin.com>, "joel@....id.au"
<joel@....id.au>, "andrew@...econstruct.com.au"
<andrew@...econstruct.com.au>, "linux-aspeed@...ts.ozlabs.org"
<linux-aspeed@...ts.ozlabs.org>, "openbmc@...ts.ozlabs.org"
<openbmc@...ts.ozlabs.org>, "linux-spi@...r.kernel.org"
<linux-spi@...r.kernel.org>, "linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, BMC-SW <BMC-SW@...eedtech.com>
Subject: RE: [PATCH v2 1/2] spi: spi-mem: Protect dirmap_create() with
spi_mem_access_start/end
Hi Paul,
Thanks for the review.
> -----Original Message-----
> From: Paul Menzel <pmenzel@...gen.mpg.de>
> Sent: Sunday, January 18, 2026 7:47 AM
> Subject: Re: [PATCH v2 1/2] spi: spi-mem: Protect dirmap_create() with
> spi_mem_access_start/end
>
> 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.
>
Yes, I verified this with a scenario where an SPI TPM is connected to CS0 of a SPI controller, while an SPI NOR flash is connected to CS1 of the same controller. I will add this description to the next patch version.
> > Signed-off-by: Chin-Ting Kuo <chin-ting_kuo@...eedtech.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@...gen.mpg.de>
>
>
> Kind regards,
>
> Paul
Powered by blists - more mailing lists