mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
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>
This commit is contained in:
parent
73958c651f
commit
d618382ba5
5 changed files with 20 additions and 23 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue