]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
powerpc/dma: fix an off-by-one in dma_capable
authorChristoph Hellwig <hch@lst.de>
Wed, 13 Feb 2019 07:01:21 +0000 (08:01 +0100)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 18 Feb 2019 11:41:03 +0000 (22:41 +1100)
We need to compare the last byte in the dma range and not the one after it
for the bus_dma_mask, just like we do for the regular dma_mask.  Fix this
cleanly by merging the two comparisms into one.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/dma-direct.h

index e00ab5d0612d39983591fd91c009dd0803699bf0..92d8aed86422480d7efa58d001615ffde8c35e77 100644 (file)
@@ -4,15 +4,11 @@
 
 static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
 {
-#ifdef CONFIG_SWIOTLB
-       if (dev->bus_dma_mask && addr + size > dev->bus_dma_mask)
-               return false;
-#endif
-
        if (!dev->dma_mask)
                return false;
 
-       return addr + size - 1 <= *dev->dma_mask;
+       return addr + size - 1 <=
+               min_not_zero(*dev->dma_mask, dev->bus_dma_mask);
 }
 
 static inline dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr)