gpu: nvgpu: re-enable elpg after golden img init

Typically, the PMU init thread will finish up long
before the golden context image has been initialized,
which means that ELPG hasn't truly been enabled at that
point.

Create a new function, nvgpu_pmu_reenable_pg(), which
checks if elpg had been enabled (non-zero refcnt), and
if so, disables then re-enables it.

Call this function from nvgpu_gr_obj_ctx_alloc() after
the golden context image has been initialized to ensure
that elpg is truly enabled.

Bug 200543218

Change-Id: I0e7c4f64434c5e356829581950edce61cc88882a
Signed-off-by: Peter Daifuku <pdaifuku@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2245768
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Peter Daifuku
2019-11-22 16:40:41 -08:00
committed by Alex Waterman
parent 7de9f2c331
commit fa8ca3fb19
3 changed files with 46 additions and 2 deletions

View File

@@ -24,8 +24,9 @@
#include <nvgpu/log.h>
#include <nvgpu/io.h>
#include <nvgpu/mm.h>
#ifdef CONFIG_NVGPU_LS_PMU
#ifdef CONFIG_NVGPU_POWER_PG
#include <nvgpu/pmu/pmu_pg.h>
#include <nvgpu/power_features/pg.h>
#endif
#include <nvgpu/gr/ctx.h>
#include <nvgpu/gr/subctx.h>
@@ -792,13 +793,25 @@ int nvgpu_gr_obj_ctx_alloc(struct gk20a *g,
nvgpu_gr_obj_ctx_commit_inst(g, inst_block, gr_ctx, subctx,
nvgpu_gr_ctx_get_ctx_mem(gr_ctx)->gpu_va);
/* init golden image, ELPG enabled after this is done */
/* init golden image */
err = nvgpu_gr_obj_ctx_alloc_golden_ctx_image(g, golden_image,
global_ctx_buffer, config, gr_ctx, inst_block);
if (err != 0) {
nvgpu_err(g, "fail to init golden ctx image");
goto out;
}
#ifdef CONFIG_NVGPU_POWER_PG
/* Re-enable ELPG now that golden image has been initialized.
* The PMU PG init code may already have tried to enable elpg, but
* would not have been able to complete this action since the golden
* image hadn't been initialized yet, so do this now.
*/
err = nvgpu_pmu_reenable_elpg(g);
if (err != 0) {
nvgpu_err(g, "fail to re-enable elpg");
goto out;
}
#endif
/* load golden image */
err = nvgpu_gr_ctx_load_golden_ctx_image(g, gr_ctx,

View File

@@ -468,6 +468,36 @@ exit_unlock:
return ret;
}
int nvgpu_pmu_reenable_elpg(struct gk20a *g)
{
struct nvgpu_pmu *pmu = g->pmu;
int ret = 0;
nvgpu_log_fn(g, " ");
if (!is_pg_supported(g, pmu->pg)) {
return ret;
}
/* If pmu enabled, re-enable by first disabling, then
* enabling.
*/
if (pmu->pg->elpg_refcnt != 0) {
ret = nvgpu_pmu_disable_elpg(g);
if (ret != 0) {
nvgpu_err(g, "failed disabling elpg");
goto exit;
}
ret = nvgpu_pmu_enable_elpg(g);
if (ret != 0) {
nvgpu_err(g, "failed enabling elpg");
goto exit;
}
}
exit:
return ret;
}
/* PG init */
static void pmu_handle_pg_stat_msg(struct gk20a *g, struct pmu_msg *msg,
void *param, u32 status)

View File

@@ -123,6 +123,7 @@ void nvgpu_pmu_pg_destroy(struct gk20a *g, struct nvgpu_pmu *pmu,
struct nvgpu_pmu_pg *pg);
/* PG enable/disable */
int nvgpu_pmu_reenable_elpg(struct gk20a *g);
int nvgpu_pmu_enable_elpg(struct gk20a *g);
int nvgpu_pmu_disable_elpg(struct gk20a *g);
int nvgpu_pmu_pg_global_enable(struct gk20a *g, bool enable_pg);