Re: [PATCH 00/21] dma-mapping: unify support for cache flushes

From
Catalin Marinas <catalin.marinas@arm.com>
Date
2023-03-31 16:54:39
Also in
linux-arm-kernel, linux-m68k, linux-mips, linux-riscv, linux-sh, lkml, sparclinux
Reply to
Arnd Bergmann, 2023-03-27
On Mon, Mar 27, 2023 at 02:12:56PM +0200, Arnd Bergmann wrote:
Another difference that I do not address here is what cache invalidation
does for partical cache lines. On arm32, arm64 and powerpc, a partial
cache line always gets written back before invalidation in order to
ensure that data before or after the buffer is not discarded. On all
other architectures, the assumption is cache lines are never shared
between DMA buffer and data that is accessed by the CPU.
I don't think sharing the DMA buffer with other data is safe even with
this clean+invalidate on the unaligned cache. Mapping the DMA buffer as
FROM_DEVICE or BIDIRECTIONAL can cause the shared cache line to be
evicted and override the device written data. This sharing only works if
the CPU guarantees not to dirty the corresponding cache line.

I'm fine with removing this partial cache line hack from arm64 as it's
not safe anyway. We'll see if any driver stops working. If there's some
benign sharing (I wouldn't trust it), the cache cleaning prior to
mapping and invalidate on unmap would not lose any data.

-- 
Catalin
Thread (75 messages) 75 messages, 21 authors, last reply 2023-07-06
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help