Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dma-direct: prevent SWIOTLB path when DMA_ATTR_REQUIRE_COHERENT is set

DMA_ATTR_REQUIRE_COHERENT indicates that SWIOTLB must not be used.
Ensure the SWIOTLB path is declined whenever the DMA direct path is
selected.

Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Link: https://lore.kernel.org/r/20260316-dma-debug-overlap-v3-5-1dde90a7f08b@nvidia.com

authored by

Leon Romanovsky and committed by
Marek Szyprowski
2536617f e6a58fa2

+4 -3
+4 -3
kernel/dma/direct.h
··· 84 84 dma_addr_t dma_addr; 85 85 86 86 if (is_swiotlb_force_bounce(dev)) { 87 - if (attrs & DMA_ATTR_MMIO) 87 + if (attrs & (DMA_ATTR_MMIO | DMA_ATTR_REQUIRE_COHERENT)) 88 88 return DMA_MAPPING_ERROR; 89 89 90 90 return swiotlb_map(dev, phys, size, dir, attrs); ··· 98 98 dma_addr = phys_to_dma(dev, phys); 99 99 if (unlikely(!dma_capable(dev, dma_addr, size, true)) || 100 100 dma_kmalloc_needs_bounce(dev, size, dir)) { 101 - if (is_swiotlb_active(dev)) 101 + if (is_swiotlb_active(dev) && 102 + !(attrs & DMA_ATTR_REQUIRE_COHERENT)) 102 103 return swiotlb_map(dev, phys, size, dir, attrs); 103 104 104 105 goto err_overflow; ··· 124 123 { 125 124 phys_addr_t phys; 126 125 127 - if (attrs & DMA_ATTR_MMIO) 126 + if (attrs & (DMA_ATTR_MMIO | DMA_ATTR_REQUIRE_COHERENT)) 128 127 /* nothing to do: uncached and no swiotlb */ 129 128 return; 130 129