From 264691e69d825489e0a0bcee56f700e241186bb4 Mon Sep 17 00:00:00 2001 From: Peter Daifuku Date: Fri, 22 Nov 2019 16:40:41 -0800 Subject: 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 gk20a_alloc_obj_ctx() after the golden context image has been initialized to ensure that elpg is truly enabled. Manually ported from dev-main Bug 200543218 Change-Id: I0e7c4f64434c5e356829581950edce61cc88882a Signed-off-by: Peter Daifuku Reviewed-on: https://git-master.nvidia.com/r/2245768 (cherry picked from commit 077b6712b5a40340ece818416002ac8431dc4138) Reviewed-on: https://git-master.nvidia.com/r/2250091 GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu Reviewed-by: Bibek Basu Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/pmu/pmu_pg.c | 32 +++++++++++++++++++++++++++++++- drivers/gpu/nvgpu/gk20a/gr_gk20a.c | 15 +++++++++++++-- drivers/gpu/nvgpu/include/nvgpu/pmu.h | 1 + 3 files changed, 45 insertions(+), 3 deletions(-) (limited to 'drivers/gpu/nvgpu') diff --git a/drivers/gpu/nvgpu/common/pmu/pmu_pg.c b/drivers/gpu/nvgpu/common/pmu/pmu_pg.c index 3d46298d..941cee75 100644 --- a/drivers/gpu/nvgpu/common/pmu/pmu_pg.c +++ b/drivers/gpu/nvgpu/common/pmu/pmu_pg.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2016-2019, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -359,6 +359,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 (!g->support_pmu) { + return ret; + } + + /* If pmu enabled, re-enable by first disabling, then + * enabling + */ + if (pmu->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 handle, u32 status) diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c index 4f8006b2..223937c6 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c @@ -1,7 +1,7 @@ /* * GK20A Graphics * - * Copyright (c) 2011-2018, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2011-2019, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -3128,7 +3128,7 @@ int gk20a_alloc_obj_ctx(struct channel_gk20a *c, u32 class_num, u32 flags) goto out; } - /* init golden image, ELPG enabled after this is done */ + /* init golden image */ err = gr_gk20a_init_golden_ctx_image(g, c); if (err != 0) { nvgpu_err(g, @@ -3136,6 +3136,17 @@ int gk20a_alloc_obj_ctx(struct channel_gk20a *c, u32 class_num, u32 flags) goto out; } + /* 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; + } + /* load golden image */ gr_gk20a_load_golden_ctx_image(g, c); if (err != 0) { diff --git a/drivers/gpu/nvgpu/include/nvgpu/pmu.h b/drivers/gpu/nvgpu/include/nvgpu/pmu.h index dcd49481..2b745c76 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/pmu.h +++ b/drivers/gpu/nvgpu/include/nvgpu/pmu.h @@ -495,6 +495,7 @@ void nvgpu_pmu_setup_hw_load_zbc(struct gk20a *g); int nvgpu_pmu_reset(struct gk20a *g); /* 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, u32 enable_pg); -- cgit v1.2.2