Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
dma-direct: only limit the mapping size if swiotlb could be used
Browse files Browse the repository at this point in the history
Don't just check for a swiotlb buffer, but also if buffering might
be required for this particular device.

Fixes: 133d624 ("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>
  • Loading branch information
Christoph Hellwig committed Jul 17, 2019
1 parent b866455 commit a5008b5
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions kernel/dma/direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 size = SIZE_MAX;

/* If SWIOTLB is active, use its maximum mapping size */
if (is_swiotlb_active())
size = swiotlb_max_mapping_size(dev);

return size;
if (is_swiotlb_active() &&
(dma_addressing_limited(dev) || swiotlb_force == SWIOTLB_FORCE))
return swiotlb_max_mapping_size(dev);
return SIZE_MAX;
}

0 comments on commit a5008b5

Please sign in to comment.