msm: mdss: fix race condition between iommu attach and sending DCS cmds

There might be cases during bootup when backlight cmds or ESD thread
sends DCS cmds to the panel when iommu attach is yet to happen. DSI
uses physical or virtual address based on the iommu_attached status
check. If iommu attach happens when the DCS cmds are using the
physical address, it would lead to SMMU page faults. Protect iommu
attach/detach and DCS cmd sending with an iommu_lock to avoid such
race conditions.

Change-Id: I16fb0bf884f0dbbce1cd9099ec5619d132379054
Signed-off-by: Veera Sundaram Sankaran <veeras@codeaurora.org>
This commit is contained in:
Veera Sundaram Sankaran 2016-07-18 18:35:06 -07:00
parent bd9b403682
commit 1d2302bdf2

View file

@ -172,6 +172,7 @@ static int mdss_smmu_attach_v2(struct mdss_data_type *mdata)
struct mdss_smmu_client *mdss_smmu;
int i, rc = 0;
mutex_lock(&mdp_iommu_lock);
for (i = 0; i < MDSS_IOMMU_MAX_DOMAIN; i++) {
if (!mdss_smmu_is_valid_domain_type(mdata, i))
continue;
@ -203,9 +204,12 @@ static int mdss_smmu_attach_v2(struct mdss_data_type *mdata)
}
} else {
pr_err("iommu device not attached for domain[%d]\n", i);
mutex_unlock(&mdp_iommu_lock);
return -ENODEV;
}
}
mutex_unlock(&mdp_iommu_lock);
return 0;
err:
@ -217,6 +221,8 @@ err:
mdss_smmu->domain_attached = false;
}
}
mutex_unlock(&mdp_iommu_lock);
return rc;
}
@ -231,6 +237,7 @@ static int mdss_smmu_detach_v2(struct mdss_data_type *mdata)
struct mdss_smmu_client *mdss_smmu;
int i;
mutex_lock(&mdp_iommu_lock);
for (i = 0; i < MDSS_IOMMU_MAX_DOMAIN; i++) {
if (!mdss_smmu_is_valid_domain_type(mdata, i))
continue;
@ -239,6 +246,8 @@ static int mdss_smmu_detach_v2(struct mdss_data_type *mdata)
if (mdss_smmu && mdss_smmu->dev && !mdss_smmu->handoff_pending)
mdss_smmu_enable_power(mdss_smmu, false);
}
mutex_unlock(&mdp_iommu_lock);
return 0;
}