aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/dma-direct.h
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2019-11-19 17:38:58 +0100
committerChristoph Hellwig <hch@lst.de>2019-11-20 20:31:41 +0100
commit68a33b1794665ba8a1d1ef1d3bfcc7c587d380a6 (patch)
treefa623a6dfd451c161630422aafd0bec2fe486285 /include/linux/dma-direct.h
parentdma-direct: don't check swiotlb=force in dma_direct_map_resource (diff)
downloadlinux-dev-68a33b1794665ba8a1d1ef1d3bfcc7c587d380a6.tar.xz
linux-dev-68a33b1794665ba8a1d1ef1d3bfcc7c587d380a6.zip
dma-direct: exclude dma_direct_map_resource from the min_low_pfn check
The valid memory address check in dma_capable only makes sense when mapping normal memory, not when using dma_map_resource to map a device resource. Add a new boolean argument to dma_capable to exclude that check for the dma_map_resource case. Fixes: b12d66278dd6 ("dma-direct: check for overflows on 32 bit DMA addresses") Reported-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Diffstat (limited to 'include/linux/dma-direct.h')
-rw-r--r--include/linux/dma-direct.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h
index f8959f75e496..99b77dd5f79b 100644
--- a/include/linux/dma-direct.h
+++ b/include/linux/dma-direct.h
@@ -49,14 +49,15 @@ static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
return __sme_clr(__dma_to_phys(dev, daddr));
}
-static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
+static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size,
+ bool is_ram)
{
dma_addr_t end = addr + size - 1;
if (!dev->dma_mask)
return false;
- if (!IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) &&
+ if (is_ram && !IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) &&
min(addr, end) < phys_to_dma(dev, PFN_PHYS(min_low_pfn)))
return false;