2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2025-01-22 20:43:56 +08:00

dma-direct: only limit the mapping size if swiotlb could be used

Don't just check for a swiotlb buffer, but also if buffering might
be required for this particular device.

Fixes: 133d624b1c ("dma: Introduce dma_max_mapping_size()")
Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
This commit is contained in:
Christoph Hellwig 2019-07-16 22:00:54 +02:00
parent b866455423
commit a5008b59cd

View File

@ -399,11 +399,9 @@ int dma_direct_supported(struct device *dev, u64 mask)
size_t dma_direct_max_mapping_size(struct device *dev) size_t dma_direct_max_mapping_size(struct device *dev)
{ {
size_t size = SIZE_MAX;
/* If SWIOTLB is active, use its maximum mapping size */ /* If SWIOTLB is active, use its maximum mapping size */
if (is_swiotlb_active()) if (is_swiotlb_active() &&
size = swiotlb_max_mapping_size(dev); (dma_addressing_limited(dev) || swiotlb_force == SWIOTLB_FORCE))
return swiotlb_max_mapping_size(dev);
return size; return SIZE_MAX;
} }