]> git.ipfire.org Git - thirdparty/linux.git/commit
dmaengine: altera-msgdma: Use memcpy_toio for descriptor FIFO writes
authorAdrian Ng Ho Yin <adrianhoyin.ng@altera.com>
Mon, 25 May 2026 08:37:30 +0000 (01:37 -0700)
committerVinod Koul <vkoul@kernel.org>
Thu, 11 Jun 2026 05:27:49 +0000 (10:57 +0530)
commit94963138cce29f85605d76c94fa1d43a0335ead9
tree25f3811fa30dd7f36658fc6447c003534fd4fabc
parent75b28d74f90c79e788e0e86caf0173fc0b2e92aa
dmaengine: altera-msgdma: Use memcpy_toio for descriptor FIFO writes

The descriptor FIFO requires that all words of a descriptor are written
in order, with the control word written last to flush it into the DMA
engine. Using memcpy() with __force to __iomem is not the correct API
and does not guarantee appropriate MMIO access on all architectures.

Replace the descriptor body copy with memcpy_toio(), using
offsetof(struct msgdma_extended_desc, control) to exclude the control
word. This matches the previous sizeof(desc->hw_desc) - sizeof(u32)
length only when control is the last struct member; add a static_assert
to enforce that layout so a future field after control cannot silently
break FIFO ordering.

Keep writing the control word separately with write barriers, so it
remains the final word pushed into the FIFO.

Signed-off-by: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
Signed-off-by: Tze Yee Ng <tze.yee.ng@altera.com>
Link: https://patch.msgid.link/f6f3b4a2e2eb0eb1a51976de3f5d1ef5bab9bd76.1779697226.git.tze.yee.ng@altera.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/altera-msgdma.c