* [PATCH] spi: dw: Fix missing smp_mb() in dw_spi_exec_mem_op
@ 2026-10-10 15:15 Jisheng Zhang
2026-10-13 22:10 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: Jisheng Zhang @ 2026-10-10 15:15 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-spi, linux-kernel
Similar as commit bfda044533b2 ("spi: dw: use "smp_mb()" to avoid
sending spi data error"), we also need the smp_mb() in
dw_spi_exec_mem_op() after setting up the members in "dws" to ensure
the data change is visible for all CPUs.
Fixes: 6423207e57ea ("spi: dw: Add memory operations support")
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
---
drivers/spi/spi-dw-core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c
index 2d671e31413e..90af2cc9e17d 100644
--- a/drivers/spi/spi-dw-core.c
+++ b/drivers/spi/spi-dw-core.c
@@ -842,6 +842,9 @@ static int dw_spi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op)
cfg.tmode = DW_SPI_CTRLR0_TMOD_TO;
}
+ /* Ensure the data change in dw_spi_init_mem_buf() is visible for all CPUs */
+ smp_mb();
+
dw_spi_enable_chip(dws, 0);
dw_spi_update_config(dws, mem->spi, &cfg, NULL);
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] spi: dw: Fix missing smp_mb() in dw_spi_exec_mem_op
2026-10-10 15:15 [PATCH] spi: dw: Fix missing smp_mb() in dw_spi_exec_mem_op Jisheng Zhang
@ 2026-10-13 22:10 ` Mark Brown
2026-10-14 4:15 ` Jisheng Zhang
0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2026-10-13 22:10 UTC (permalink / raw)
To: Jisheng Zhang; +Cc: linux-spi, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 621 bytes --]
On Sat, Oct 10, 2026 at 11:15:29PM +0800, Jisheng Zhang wrote:
> Similar as commit bfda044533b2 ("spi: dw: use "smp_mb()" to avoid
> sending spi data error"), we also need the smp_mb() in
> dw_spi_exec_mem_op() after setting up the members in "dws" to ensure
> the data change is visible for all CPUs.
Which other CPUs are we worried about here? Unlike the regular SPI path
which can use DMA and interrupts for the exec_op() stuff we only do PIO
and have interrupts masked during the actual transfer. If the task
migrates I'd expect that to have all the required barriers, but
otherwise it all looks single threaded.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] spi: dw: Fix missing smp_mb() in dw_spi_exec_mem_op
2026-10-13 22:10 ` Mark Brown
@ 2026-10-14 4:15 ` Jisheng Zhang
0 siblings, 0 replies; 3+ messages in thread
From: Jisheng Zhang @ 2026-10-14 4:15 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-spi, linux-kernel
On Tue, Oct 13, 2026 at 11:10:09PM +0100, Mark Brown wrote:
> On Sat, Oct 10, 2026 at 11:15:29PM +0800, Jisheng Zhang wrote:
>
> > Similar as commit bfda044533b2 ("spi: dw: use "smp_mb()" to avoid
> > sending spi data error"), we also need the smp_mb() in
> > dw_spi_exec_mem_op() after setting up the members in "dws" to ensure
> > the data change is visible for all CPUs.
>
> Which other CPUs are we worried about here? Unlike the regular SPI path
> which can use DMA and interrupts for the exec_op() stuff we only do PIO
> and have interrupts masked during the actual transfer. If the task
> migrates I'd expect that to have all the required barriers, but
> otherwise it all looks single threaded.
You are right. This patch isn't needed. Thanks for the explaination.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-14 4:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-10 15:15 [PATCH] spi: dw: Fix missing smp_mb() in dw_spi_exec_mem_op Jisheng Zhang
2026-10-13 22:10 ` Mark Brown
2026-10-14 4:15 ` Jisheng Zhang
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®