Skip to content

Commit

Permalink
kernel/dma/direct: take DMA offset into account in dma_direct_supported
Browse files Browse the repository at this point in the history
When a device has a DMA offset the dma capable result will change due
to the difference between the physical and DMA address.  Take that into
account.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
  • Loading branch information
Christoph Hellwig committed Sep 1, 2018
1 parent 5b394b2 commit c1d0af1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/dma/direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents,
int dma_direct_supported(struct device *dev, u64 mask)
{
#ifdef CONFIG_ZONE_DMA
if (mask < DMA_BIT_MASK(ARCH_ZONE_DMA_BITS))
if (mask < phys_to_dma(dev, DMA_BIT_MASK(ARCH_ZONE_DMA_BITS)))
return 0;
#else
/*
Expand All @@ -177,7 +177,7 @@ int dma_direct_supported(struct device *dev, u64 mask)
* memory, or by providing a ZONE_DMA32. If neither is the case, the
* architecture needs to use an IOMMU instead of the direct mapping.
*/
if (mask < DMA_BIT_MASK(32))
if (mask < phys_to_dma(dev, DMA_BIT_MASK(32)))
return 0;
#endif
/*
Expand Down

0 comments on commit c1d0af1

Please sign in to comment.