On Mon, Nov 27, 2023 at 11:02:20AM -0500, Alan Stern wrote: > All it looks for is mappings that start on the same cache line. However > on architectures that have cache-coherent DMA (such as x86), touching > the same cache line does not mean that two DMA mappings will interfere > with each other. To truly overlap, they would have to touch the same > _bytes_. But that is a special case that does not matter. Linux drivers need to be written in a portable way, and that means we have to care about platforms that are not DMA coherent. > How should this be fixed? Since the check done in add_dma_entry() is > completely invalid for x86 and similar architectures, should it simply > be removed for them? Or should the check be enhanced to look for > byte-granularity overlap? The patch is every but "completely invalid". It points out that you violate the Linux DMA API requirements. This might not have an effect on the particular plaform you are currently running on, but it is still wrong. Note that there have been various mumblings about using nosnoop dma on x86, in which case you'll have the issue there as well. > PS: As a separate issue, active_cacheline_insert() fails to detect > overlap in situations where a mapping occupies more than one cache line. > For example, if mapping A uses lines N and N+1 and mapping B uses line > N+1, no overlap will be detected because the radix-tree keys for A and B > will be different (N vs. N+1). Fixes welcome.