video: tegra: host: gk20a: fix possible elpg race
Prashant Malani [Mon, 27 Jan 2014 23:33:54 +0000 (15:33 -0800)]
Currently, the enablement of ELPG is placed in deferred work. But,
graphics code can call elpg enable/disable before this deferred work
runs. The current enable/disable routines don't verify that gPMU has
ELPG correctly initialized (along with the PG buffers set up, which is
done in the deferred work). Therefore the driver could potentially send
ELPG commands to gPMU even when it is not completely set up to process
them. Therefore we add a check to ensure that gPMU is completely
initialized before issuing such commands.

Bug 1446194
Bug 1445308

Change-Id: I8e675ae2ab900643c70310a6b37b6dfb022469d8
Signed-off-by: Prashant Malani <pmalani@nvidia.com>
Reviewed-on: http://git-master/r/360616
(cherry picked from commit f2d3e72534ad89346a9454bfcd08ff2138d16d22)
Reviewed-on: http://git-master/r/364150
Reviewed-by: Naveen Kumar S <nkumars@nvidia.com>
Tested-by: Naveen Kumar S <nkumars@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Winnie Hsu <whsu@nvidia.com>

drivers/video/tegra/host/gk20a/pmu_gk20a.c

index fcaddd5..dbe2d41 100644 (file)
@@ -2567,7 +2567,7 @@ int gk20a_pmu_enable_elpg(struct gk20a *g)
 
        nvhost_dbg_fn("");
 
-       if (!pmu->elpg_ready)
+       if (!pmu->elpg_ready || !pmu->initialized)
                goto exit;
 
        mutex_lock(&pmu->elpg_mutex);
@@ -2640,7 +2640,7 @@ static int gk20a_pmu_disable_elpg_defer_enable(struct gk20a *g, bool enable)
 
        nvhost_dbg_fn("");
 
-       if (!pmu->elpg_ready)
+       if (!pmu->elpg_ready || !pmu->initialized)
                return 0;
 
        /* remove the work from queue */