Skip to content

Commit

Permalink
powerpc/dma: fix an off-by-one in dma_capable
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Christoph Hellwig authored and Michael Ellerman committed Feb 18, 2019
1 parent 74194cd commit 9b18114
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions arch/powerpc/include/asm/dma-direct.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9b18114

Please sign in to comment.