diff options
-rw-r--r-- | arch/ia64/include/asm/dma-mapping.h | 2 | ||||
-rw-r--r-- | arch/powerpc/include/asm/dma-mapping.h | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/dma-mapping.h | 2 | ||||
-rw-r--r-- | lib/swiotlb.c | 4 |
4 files changed, 5 insertions, 5 deletions
diff --git a/arch/ia64/include/asm/dma-mapping.h b/arch/ia64/include/asm/dma-mapping.h index 8d3c79cd81e7..7d09a09cdaad 100644 --- a/arch/ia64/include/asm/dma-mapping.h +++ b/arch/ia64/include/asm/dma-mapping.h | |||
@@ -73,7 +73,7 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) | |||
73 | if (!dev->dma_mask) | 73 | if (!dev->dma_mask) |
74 | return 0; | 74 | return 0; |
75 | 75 | ||
76 | return addr + size <= *dev->dma_mask; | 76 | return addr + size - 1 <= *dev->dma_mask; |
77 | } | 77 | } |
78 | 78 | ||
79 | static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) | 79 | static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) |
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h index e281daebddca..80a973bb9e71 100644 --- a/arch/powerpc/include/asm/dma-mapping.h +++ b/arch/powerpc/include/asm/dma-mapping.h | |||
@@ -197,7 +197,7 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) | |||
197 | if (!dev->dma_mask) | 197 | if (!dev->dma_mask) |
198 | return 0; | 198 | return 0; |
199 | 199 | ||
200 | return addr + size <= *dev->dma_mask; | 200 | return addr + size - 1 <= *dev->dma_mask; |
201 | } | 201 | } |
202 | 202 | ||
203 | static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) | 203 | static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) |
diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h index 0f6c02f3b7d4..ac91eed21061 100644 --- a/arch/x86/include/asm/dma-mapping.h +++ b/arch/x86/include/asm/dma-mapping.h | |||
@@ -67,7 +67,7 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) | |||
67 | if (!dev->dma_mask) | 67 | if (!dev->dma_mask) |
68 | return 0; | 68 | return 0; |
69 | 69 | ||
70 | return addr + size <= *dev->dma_mask; | 70 | return addr + size - 1 <= *dev->dma_mask; |
71 | } | 71 | } |
72 | 72 | ||
73 | static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) | 73 | static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) |
diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 5bc01803f8f8..437eedb5a53b 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c | |||
@@ -549,7 +549,7 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size, | |||
549 | dma_mask = hwdev->coherent_dma_mask; | 549 | dma_mask = hwdev->coherent_dma_mask; |
550 | 550 | ||
551 | ret = (void *)__get_free_pages(flags, order); | 551 | ret = (void *)__get_free_pages(flags, order); |
552 | if (ret && swiotlb_virt_to_bus(hwdev, ret) + size > dma_mask) { | 552 | if (ret && swiotlb_virt_to_bus(hwdev, ret) + size - 1 > dma_mask) { |
553 | /* | 553 | /* |
554 | * The allocated memory isn't reachable by the device. | 554 | * The allocated memory isn't reachable by the device. |
555 | */ | 555 | */ |
@@ -571,7 +571,7 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size, | |||
571 | dev_addr = swiotlb_virt_to_bus(hwdev, ret); | 571 | dev_addr = swiotlb_virt_to_bus(hwdev, ret); |
572 | 572 | ||
573 | /* Confirm address can be DMA'd by device */ | 573 | /* Confirm address can be DMA'd by device */ |
574 | if (dev_addr + size > dma_mask) { | 574 | if (dev_addr + size - 1 > dma_mask) { |
575 | printk("hwdev DMA mask = 0x%016Lx, dev_addr = 0x%016Lx\n", | 575 | printk("hwdev DMA mask = 0x%016Lx, dev_addr = 0x%016Lx\n", |
576 | (unsigned long long)dma_mask, | 576 | (unsigned long long)dma_mask, |
577 | (unsigned long long)dev_addr); | 577 | (unsigned long long)dev_addr); |