drm/msm: Free all allocated resources in case hardware init fails

Turn off the GPU power and free all resources allocated during
GPU init in case hardware init fails in adreno_gpu_load. This is
required to make sure further tries to load the GPU again doesn't
fail because of invalid GPU state.

Change-Id: I1d0d68f62be751d76274975e098364131712ca38
Signed-off-by: Deepak Kumar <dkumar@codeaurora.org>
This commit is contained in:
Deepak Kumar 2017-07-27 11:03:45 +05:30
parent a49bb61510
commit cfa0dc2093
2 changed files with 21 additions and 0 deletions

View file

@ -173,6 +173,9 @@ struct msm_gpu *adreno_load_gpu(struct drm_device *dev)
ret = gpu->funcs->hw_init(gpu);
if (ret) {
dev_err(dev->dev, "gpu hw init failed: %d\n", ret);
mutex_lock(&dev->struct_mutex);
gpu->funcs->pm_suspend(gpu);
mutex_unlock(&dev->struct_mutex);
gpu->funcs->destroy(gpu);
gpu = NULL;
} else {

View file

@ -1028,4 +1028,22 @@ void msm_gpu_cleanup(struct msm_gpu *gpu)
msm_gpu_destroy_address_space(gpu->aspace);
msm_gpu_destroy_address_space(gpu->secure_aspace);
if (gpu->gpu_reg)
devm_regulator_put(gpu->gpu_reg);
if (gpu->gpu_cx)
devm_regulator_put(gpu->gpu_cx);
if (gpu->ebi1_clk)
devm_clk_put(&pdev->dev, gpu->ebi1_clk);
for (i = gpu->nr_clocks - 1; i >= 0; i--)
if (gpu->grp_clks[i])
devm_clk_put(&pdev->dev, gpu->grp_clks[i]);
devm_kfree(&pdev->dev, gpu->grp_clks);
if (gpu->mmio)
devm_iounmap(&pdev->dev, gpu->mmio);
}