From f4571194b02094c7d447052bf0b411a44582ef09 Mon Sep 17 00:00:00 2001 From: Sagar Kamble Date: Tue, 10 Aug 2021 16:58:04 +0530 Subject: [PATCH] gpu: nvgpu: stop ELPG init thread during unload ELPG initialization thread creation can fail when the process is killed. That leads to driver resume failure. That thread was stopped on suspend and re-created on resume. To avoid the issue above, don't stop the ELPG thread in suspend and let the first created thread handle the ELPG state transitions always. And stop the ELPG thread during unload. Also fix couple of instances of config flag as: s/CONFIG_PMU_POWER_PG/CONFIG_NVGPU_POWER_PG bug 3345977 Change-Id: I8952edf8d1664ed258f238e265002e716d1bf5c2 Signed-off-by: Sagar Kamble Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2573763 Reviewed-by: svc_kernel_abi Reviewed-by: Konsta Holtta Reviewed-by: Vijayakumar Subbu Reviewed-by: mobile promotions Tested-by: Ashish Mhetre Tested-by: mobile promotions GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/common/pmu/pg/pmu_pg.c | 12 ++++++++---- drivers/gpu/nvgpu/common/pmu/pmu_rtos_init.c | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/nvgpu/common/pmu/pg/pmu_pg.c b/drivers/gpu/nvgpu/common/pmu/pg/pmu_pg.c index d66fde938..baaf08da3 100644 --- a/drivers/gpu/nvgpu/common/pmu/pg/pmu_pg.c +++ b/drivers/gpu/nvgpu/common/pmu/pg/pmu_pg.c @@ -704,8 +704,8 @@ static int pmu_pg_task(void *arg) case PMU_FW_STATE_LOADING_ZBC: nvgpu_pmu_dbg(g, "loaded zbc"); err = pmu_pg_setup_hw_enable_elpg(g, pmu, pmu->pg); - nvgpu_pmu_dbg(g, "PMU booted, thread exiting"); - return 0; + nvgpu_pmu_dbg(g, "PMU booted"); + break; default: nvgpu_pmu_dbg(g, "invalid state"); err = -EINVAL; @@ -797,6 +797,10 @@ int nvgpu_pmu_pg_sw_setup(struct gk20a *g, struct nvgpu_pmu *pmu, } } + if (nvgpu_thread_is_running(&pg->pg_init.state_task)) { + return 0; + } + /* Create thread to handle PMU state machine */ return pmu_pg_task_init(g, pg); } @@ -810,8 +814,6 @@ void nvgpu_pmu_pg_destroy(struct gk20a *g, struct nvgpu_pmu *pmu, return; } - pmu_pg_kill_task(g, pmu, pg); - nvgpu_pmu_get_pg_stats(g, PMU_PG_ELPG_ENGINE_ID_GRAPHICS, &pg_stat_data); @@ -905,6 +907,8 @@ void nvgpu_pmu_pg_deinit(struct gk20a *g, struct nvgpu_pmu *pmu, return; } + pmu_pg_kill_task(g, pmu, pg); + if (nvgpu_mem_is_valid(&pg->seq_buf)) { nvgpu_dma_unmap_free(vm, &pg->seq_buf); } diff --git a/drivers/gpu/nvgpu/common/pmu/pmu_rtos_init.c b/drivers/gpu/nvgpu/common/pmu/pmu_rtos_init.c index c33b80782..694294794 100644 --- a/drivers/gpu/nvgpu/common/pmu/pmu_rtos_init.c +++ b/drivers/gpu/nvgpu/common/pmu/pmu_rtos_init.c @@ -91,7 +91,7 @@ int nvgpu_pmu_lock_release(struct gk20a *g, struct nvgpu_pmu *pmu, return 0; } -#ifdef CONFIG_PMU_POWER_PG +#ifdef CONFIG_NVGPU_POWER_PG if (!pmu->pg->initialized) { return -EINVAL; } @@ -169,7 +169,7 @@ static void remove_pmu_support(struct nvgpu_pmu *pmu) nvgpu_pmu_debug_deinit(g, pmu); nvgpu_pmu_lsfm_deinit(g, pmu, pmu->lsfm); -#ifdef CONFIG_PMU_POWER_PG +#ifdef CONFIG_NVGPU_POWER_PG nvgpu_pmu_pg_deinit(g, pmu, pmu->pg); #endif nvgpu_pmu_sequences_deinit(g, pmu, pmu->sequences);