linux/kernel/dma
Mikhail Gavrilov 3d48c9fd78 dma-debug: suppress cacheline overlap warning when arch has no DMA alignment requirement
When CONFIG_DMA_API_DEBUG is enabled, the DMA debug infrastructure
tracks active mappings per cacheline and warns if two different DMA
mappings share the same cacheline ("cacheline tracking EEXIST,
overlapping mappings aren't supported").

On x86_64, ARCH_KMALLOC_MINALIGN defaults to 8, so small kmalloc
allocations (e.g. the 8-byte hub->buffer and hub->status in the USB
hub driver) frequently land in the same 64-byte cacheline.  When both
are DMA-mapped, this triggers a false positive warning.

This has been reported repeatedly since v5.14 (when the EEXIST check
was added) across various USB host controllers and devices including
xhci_hcd with USB hubs, USB audio devices, and USB ethernet adapters.

The cacheline overlap is only a real concern on architectures that
require DMA buffer alignment to cacheline boundaries (i.e. where
ARCH_DMA_MINALIGN >= L1_CACHE_BYTES).  On architectures like x86_64
where dma_get_cache_alignment() returns 1, the hardware is
cache-coherent and overlapping cacheline mappings are harmless.

Suppress the EEXIST warning when dma_get_cache_alignment() is less
than L1_CACHE_BYTES, indicating the architecture does not require
cacheline-aligned DMA buffers.

Verified with a kernel module reproducer that performs two kmalloc(8)
allocations back-to-back and DMA-maps both:

  Before: allocations share a cacheline, EEXIST fires within ~50 pairs
  After:  same cacheline pair found, but no warning emitted

Fixes: 2b4bbc6231 ("dma-debug: report -EEXIST errors in add_dma_entry")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=215740
Suggested-by: Harry Yoo <harry@kernel.org>
Tested-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
Signed-off-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Link: https://lore.kernel.org/r/20260327124156.24820-1-mikhail.v.gavrilov@gmail.com
2026-03-30 09:41:18 +02:00
..
Kconfig dma-mapping: Remove dma_mark_clean (again) 2026-01-08 00:19:08 +01:00
Makefile dma-mapping: clearly mark DMA ops as an architecture feature 2024-09-04 07:08:51 +03:00
coherent.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
contiguous.c dma: contiguous: Check return value of dma_contiguous_reserve_area() 2026-02-02 09:20:32 +01:00
debug.c dma-debug: suppress cacheline overlap warning when arch has no DMA alignment requirement 2026-03-30 09:41:18 +02:00
debug.h dma-mapping: export new dma_*map_phys() interface 2025-09-12 00:18:21 +02:00
direct.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
direct.h dma-direct: prevent SWIOTLB path when DMA_ATTR_REQUIRE_COHERENT is set 2026-03-20 12:05:56 +01:00
dummy.c dma-mapping: convert dummy ops to physical address mapping 2025-10-29 10:27:29 +01:00
map_benchmark.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
mapping.c dma-mapping: Introduce DMA require coherency attribute 2026-03-20 12:05:36 +01:00
ops_helpers.c dma-mapping: remove unused map_page callback 2025-10-29 10:27:31 +01:00
pool.c dma/pool: distinguish between missing and exhausted atomic pools 2026-01-29 10:23:45 +01:00
remap.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
swiotlb.c dma: swiotlb: add KMSAN annotations to swiotlb_bounce() 2026-03-16 11:29:20 +01:00