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: 133d624b1cee ("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>

+4 -6
+4 -6
kernel/dma/direct.c
··· 399 400 size_t dma_direct_max_mapping_size(struct device *dev) 401 { 402 - size_t size = SIZE_MAX; 403 - 404 /* If SWIOTLB is active, use its maximum mapping size */ 405 - if (is_swiotlb_active()) 406 - size = swiotlb_max_mapping_size(dev); 407 - 408 - return size; 409 }
··· 399 400 size_t dma_direct_max_mapping_size(struct device *dev) 401 { 402 /* If SWIOTLB is active, use its maximum mapping size */ 403 + if (is_swiotlb_active() && 404 + (dma_addressing_limited(dev) || swiotlb_force == SWIOTLB_FORCE)) 405 + return swiotlb_max_mapping_size(dev); 406 + return SIZE_MAX; 407 }