mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/
synced 2026-04-01 22:37:41 -04:00
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
This commit is contained in:
committed by
Marek Szyprowski
parent
e6a58fa255
commit
2536617f20
@@ -84,7 +84,7 @@ static inline dma_addr_t dma_direct_map_phys(struct device *dev,
|
||||
dma_addr_t dma_addr;
|
||||
|
||||
if (is_swiotlb_force_bounce(dev)) {
|
||||
if (attrs & DMA_ATTR_MMIO)
|
||||
if (attrs & (DMA_ATTR_MMIO | DMA_ATTR_REQUIRE_COHERENT))
|
||||
return DMA_MAPPING_ERROR;
|
||||
|
||||
return swiotlb_map(dev, phys, size, dir, attrs);
|
||||
@@ -98,7 +98,8 @@ static inline dma_addr_t dma_direct_map_phys(struct device *dev,
|
||||
dma_addr = phys_to_dma(dev, phys);
|
||||
if (unlikely(!dma_capable(dev, dma_addr, size, true)) ||
|
||||
dma_kmalloc_needs_bounce(dev, size, dir)) {
|
||||
if (is_swiotlb_active(dev))
|
||||
if (is_swiotlb_active(dev) &&
|
||||
!(attrs & DMA_ATTR_REQUIRE_COHERENT))
|
||||
return swiotlb_map(dev, phys, size, dir, attrs);
|
||||
|
||||
goto err_overflow;
|
||||
@@ -123,7 +124,7 @@ static inline void dma_direct_unmap_phys(struct device *dev, dma_addr_t addr,
|
||||
{
|
||||
phys_addr_t phys;
|
||||
|
||||
if (attrs & DMA_ATTR_MMIO)
|
||||
if (attrs & (DMA_ATTR_MMIO | DMA_ATTR_REQUIRE_COHERENT))
|
||||
/* nothing to do: uncached and no swiotlb */
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user