diff --git a/drivers/iommu/msm_iommu-v0.c b/drivers/iommu/msm_iommu-v0.c index 230f241b19e..d2dc7a0e1f4 100644 --- a/drivers/iommu/msm_iommu-v0.c +++ b/drivers/iommu/msm_iommu-v0.c @@ -55,6 +55,9 @@ struct bus_type msm_iommu_sec_bus_type = { .name = "msm_iommu_sec_bus", }; +static int msm_iommu_unmap_range(struct iommu_domain *domain, unsigned int va, + unsigned int len); + static inline void clean_pte(unsigned long *start, unsigned long *end, int redirect) { @@ -953,6 +956,7 @@ static int msm_iommu_map_range(struct iommu_domain *domain, unsigned int va, int prot) { unsigned int pa; + unsigned int start_va = va; unsigned int offset = 0; unsigned long *fl_table; unsigned long *fl_pte; @@ -1091,6 +1095,8 @@ static int msm_iommu_map_range(struct iommu_domain *domain, unsigned int va, __flush_iotlb(domain); fail: mutex_unlock(&msm_iommu_lock); + if (ret && offset > 0) + msm_iommu_unmap_range(domain, start_va, offset); return ret; } diff --git a/drivers/iommu/msm_iommu_pagetable.c b/drivers/iommu/msm_iommu_pagetable.c index cc8c605bcdf..9614692b16b 100644 --- a/drivers/iommu/msm_iommu_pagetable.c +++ b/drivers/iommu/msm_iommu_pagetable.c @@ -431,6 +431,7 @@ int msm_iommu_pagetable_map_range(struct msm_iommu_pt *pt, unsigned int va, struct scatterlist *sg, unsigned int len, int prot) { phys_addr_t pa; + unsigned int start_va = va; unsigned int offset = 0; unsigned long *fl_pte; unsigned long fl_offset; @@ -557,6 +558,9 @@ int msm_iommu_pagetable_map_range(struct msm_iommu_pt *pt, unsigned int va, } fail: + if (ret && offset > 0) + msm_iommu_pagetable_unmap_range(pt, start_va, offset); + return ret; }