summaryrefslogtreecommitdiff
path: root/drivers/gpu
diff options
context:
space:
mode:
authorLloyd Atkinson <latkinso@codeaurora.org>2016-10-04 09:51:22 -0400
committerGerrit - the friendly Code Review server <code-review@localhost>2016-11-30 11:10:54 -0800
commitb1b6408bcfd3e286e90e7c3d5f0a81c241dc131b (patch)
tree5ce78b320135884f8bee58730726107027ba1c55 /drivers/gpu
parentf547c0a044b2568a0be1a37822a3174cdd25bcb1 (diff)
drm/msm: implement smmu detach and guard freeing of client dev
Provide a basic implementation of msm_smmu_detach. Check that smmu client_dev exists before doing platform_device_unregister. Change-Id: Ied1481003d878af452d3b00b950b234c6b7dd698 Signed-off-by: Lloyd Atkinson <latkinso@codeaurora.org>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/msm/msm_smmu.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/gpu/drm/msm/msm_smmu.c b/drivers/gpu/drm/msm/msm_smmu.c
index 3aa0ed978df8..d01c25603ce7 100644
--- a/drivers/gpu/drm/msm/msm_smmu.c
+++ b/drivers/gpu/drm/msm/msm_smmu.c
@@ -82,7 +82,20 @@ static int msm_smmu_attach(struct msm_mmu *mmu, const char **names, int cnt)
static void msm_smmu_detach(struct msm_mmu *mmu, const char **names, int cnt)
{
- DBG("detaching");
+ struct msm_smmu *smmu = to_msm_smmu(mmu);
+ struct msm_smmu_client *client = msm_smmu_to_client(smmu);
+
+ if (!client) {
+ pr_err("undefined smmu client\n");
+ return;
+ }
+
+ if (!client->domain_attached)
+ return;
+
+ arm_iommu_detach_device(client->dev);
+ client->domain_attached = false;
+ dev_dbg(client->dev, "iommu domain detached\n");
}
static int msm_smmu_map(struct msm_mmu *mmu, uint32_t iova,
@@ -193,7 +206,8 @@ static void msm_smmu_destroy(struct msm_mmu *mmu)
struct msm_smmu *smmu = to_msm_smmu(mmu);
struct platform_device *pdev = to_platform_device(smmu->client_dev);
- platform_device_unregister(pdev);
+ if (smmu->client_dev)
+ platform_device_unregister(pdev);
kfree(smmu);
}