From 96d53bff8598a44fcec3f2492c8ec630d71d5dd0 Mon Sep 17 00:00:00 2001 From: Daniel Fu Date: Wed, 4 Jul 2018 23:56:26 +0800 Subject: gpu: nvgpu: avoid redundant enable/disable PG ELPG powergate is refcounted. We should not enable/disable it, if it's already so. Or it will break the PG disable/enable function. Bug 200410661 Change-Id: Ife60f373b877d1ffc441578ffa53fe0d4409eba6 Signed-off-by: Daniel Fu Reviewed-on: https://git-master.nvidia.com/r/1774265 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-misra-checker Reviewed-by: Vinod Gopalakrishnakurup GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c index ddf2039b..7ec9f5d3 100644 --- a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c @@ -232,7 +232,12 @@ int dbg_set_powergate(struct dbg_session_gk20a *dbg_s, bool disable_powergate) return err; /*do elpg disable before clock gating */ - nvgpu_pmu_pg_global_enable(g, false); + + /* we should not disabled it again, if it's already so */ + if (g->elpg_enabled) { + g->elpg_enabled = false; + nvgpu_pmu_pg_global_enable(g, false); + } if (g->ops.clock_gating.slcg_gr_load_gating_prod) g->ops.clock_gating.slcg_gr_load_gating_prod(g, @@ -276,7 +281,12 @@ int dbg_set_powergate(struct dbg_session_gk20a *dbg_s, bool disable_powergate) slcg_gr_load_gating_prod(g, g->slcg_enabled); } - nvgpu_pmu_pg_global_enable(g, true); + + /* we should not enable it again, if it's already so */ + if (!g->elpg_enabled) { + g->elpg_enabled = true; + nvgpu_pmu_pg_global_enable(g, true); + } nvgpu_log(g, gpu_dbg_gpu_dbg | gpu_dbg_fn, "module idle"); -- cgit v1.2.2