iommu: msm: prevent partial mappings on error

If msm_iommu_map_range() fails mid way through the va
range with an error, clean up the PTEs that have already
been created so they are not leaked.

Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f
CRs-Fixed: 478304
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
This commit is contained in:
Jeremy Gebben
2013-04-22 11:14:53 -07:00
committed by Laura Abbott
parent 894caf2108
commit 4b1bfae096
2 changed files with 10 additions and 0 deletions
+6
View File
@@ -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;
}
+4
View File
@@ -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;
}