summaryrefslogtreecommitdiffstats
path: root/lib/iommu-common.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2015-11-04 11:30:57 -0800
committerDavid S. Miller <davem@davemloft.net>2015-11-04 11:30:57 -0800
commitd618382ba5f1a4905db63f4980bf7b0a5826de9d (patch)
tree5bc612d222a70276b0e4d9df476b2548c1286d9e /lib/iommu-common.c
parent73958c651fbf70d8d8bf2a60b871af5f7a2e3199 (diff)
downloadlinux-d618382ba5f1a4905db63f4980bf7b0a5826de9d.tar.bz2
iommu-common: Fix error code used in iommu_tbl_range_{alloc,free}().
The value returned from iommu_tbl_range_alloc() (and the one passed in as a fourth argument to iommu_tbl_range_free) is not a DMA address, it is rather an index into the IOMMU page table. Therefore using DMA_ERROR_CODE is not appropriate. Use a more type matching error code define, IOMMU_ERROR_CODE, and update all users of this interface. Reported-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'lib/iommu-common.c')
-rw-r--r--lib/iommu-common.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/lib/iommu-common.c b/lib/iommu-common.c
index ff19f66d3f7f..0f2c887be770 100644
--- a/lib/iommu-common.c
+++ b/lib/iommu-common.c
@@ -11,10 +11,6 @@
#include <linux/dma-mapping.h>
#include <linux/hash.h>
-#ifndef DMA_ERROR_CODE
-#define DMA_ERROR_CODE (~(dma_addr_t)0x0)
-#endif
-
static unsigned long iommu_large_alloc = 15;
static DEFINE_PER_CPU(unsigned int, iommu_hash_common);
@@ -124,7 +120,7 @@ unsigned long iommu_tbl_range_alloc(struct device *dev,
/* Sanity check */
if (unlikely(npages == 0)) {
WARN_ON_ONCE(1);
- return DMA_ERROR_CODE;
+ return IOMMU_ERROR_CODE;
}
if (largealloc) {
@@ -207,7 +203,7 @@ unsigned long iommu_tbl_range_alloc(struct device *dev,
goto again;
} else {
/* give up */
- n = DMA_ERROR_CODE;
+ n = IOMMU_ERROR_CODE;
goto bail;
}
}
@@ -259,7 +255,7 @@ void iommu_tbl_range_free(struct iommu_map_table *iommu, u64 dma_addr,
unsigned long flags;
unsigned long shift = iommu->table_shift;
- if (entry == DMA_ERROR_CODE) /* use default addr->entry mapping */
+ if (entry == IOMMU_ERROR_CODE) /* use default addr->entry mapping */
entry = (dma_addr - iommu->table_map_base) >> shift;
pool = get_pool(iommu, entry);