msm_gpu_pm_resume() returns without disabling the power rails when
enabling the GPU clocks fails. If enabling the AXI clock fails, both
the GPU clocks and power rails remain enabled. In addition,
enable_pwrrail() leaves gpu_reg enabled if enabling gpu_cx fails.

Disable gpu_reg when enabling gpu_cx fails, and unwind the completed
power and clock stages in reverse order when resume fails.

Fixes: 7198e6b03155 ("drm/msm: add a3xx gpu support")
Signed-off-by: Haoxiang Li <[email protected]>
---
 drivers/gpu/drm/msm/msm_gpu.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index 8319119041eb..5480abe1aba2 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -40,6 +40,8 @@ static int enable_pwrrail(struct msm_gpu *gpu)
                ret = regulator_enable(gpu->gpu_cx);
                if (ret) {
                        DRM_DEV_ERROR(dev->dev, "failed to enable 'gpu_cx': 
%d\n", ret);
+                       if (gpu->gpu_reg)
+                               regulator_disable(gpu->gpu_reg);
                        return ret;
                }
        }
@@ -110,17 +112,24 @@ int msm_gpu_pm_resume(struct msm_gpu *gpu)
 
        ret = enable_clk(gpu);
        if (ret)
-               return ret;
+               goto err_disable_pwrrail;
 
        ret = enable_axi(gpu);
        if (ret)
-               return ret;
+               goto err_disable_clk;
 
        msm_devfreq_resume(gpu);
 
        gpu->needs_hw_init = true;
 
        return 0;
+
+err_disable_clk:
+       disable_clk(gpu);
+
+err_disable_pwrrail:
+       disable_pwrrail(gpu);
+       return ret;
 }
 
 int msm_gpu_pm_suspend(struct msm_gpu *gpu)
-- 
2.25.1

Reply via email to