From d19be32f910a6b82da2cbe02a0c5026162f5135d Mon Sep 17 00:00:00 2001 From: Mahantesh Kumbar Date: Fri, 26 Apr 2019 10:40:34 +0530 Subject: [PATCH] gpu: nvgpu: PMU debug init update Moved allocation/free of debug buffer required for PMU RTOS debug messages dump to PMU debug unit & will be called as part of sw_setup/deinit stage of PMU. JIRA NVGPU-1972 Change-Id: I4ac5f8d464548e7771fcd2a17998ff4028ea928b Signed-off-by: Mahantesh Kumbar Reviewed-on: https://git-master.nvidia.com/r/2110153 GVS: Gerrit_Virtual_Submit Reviewed-by: Ramesh Mylavarapu Reviewed-by: Vijayakumar Subbu Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/pmu/pmu.c | 6 +++--- drivers/gpu/nvgpu/common/pmu/pmu_debug.c | 26 ++++++++++++++++++++++++ drivers/gpu/nvgpu/include/nvgpu/pmu.h | 2 ++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/nvgpu/common/pmu/pmu.c b/drivers/gpu/nvgpu/common/pmu/pmu.c index 3ebe7df87..60ed1dcc8 100644 --- a/drivers/gpu/nvgpu/common/pmu/pmu.c +++ b/drivers/gpu/nvgpu/common/pmu/pmu.c @@ -180,10 +180,9 @@ static int nvgpu_init_pmu_setup_sw(struct gk20a *g) } } - err = nvgpu_dma_alloc_map(vm, GK20A_PMU_TRACE_BUFSIZE, - &pmu->trace_buf); + /* alloc shared buffer to read PMU-RTOS debug message */ + err = nvgpu_pmu_debug_init(g, pmu); if (err != 0) { - nvgpu_err(g, "failed to allocate pmu trace buffer\n"); goto err_free_super_surface; } @@ -337,6 +336,7 @@ static void nvgpu_remove_pmu_support(struct nvgpu_pmu *pmu) nvgpu_pmu_super_surface_deinit(g, pmu, pmu->super_surface); } + nvgpu_pmu_debug_deinit(g, pmu); nvgpu_pmu_lsfm_deinit(g, pmu, pmu->lsfm); nvgpu_pmu_pg_deinit(g, pmu, pmu->pg); diff --git a/drivers/gpu/nvgpu/common/pmu/pmu_debug.c b/drivers/gpu/nvgpu/common/pmu/pmu_debug.c index a800cb078..7354039ce 100644 --- a/drivers/gpu/nvgpu/common/pmu/pmu_debug.c +++ b/drivers/gpu/nvgpu/common/pmu/pmu_debug.c @@ -23,6 +23,7 @@ #include #include #include +#include bool nvgpu_find_hex_in_string(char *strings, struct gk20a *g, u32 *hex_pos) { @@ -111,3 +112,28 @@ void nvgpu_pmu_dump_falcon_stats(struct nvgpu_pmu *pmu) /* PMU may crash due to FECS crash. Dump FECS status */ g->ops.gr.falcon.dump_stats(g); } + +int nvgpu_pmu_debug_init(struct gk20a *g, struct nvgpu_pmu *pmu) +{ + struct mm_gk20a *mm = &g->mm; + struct vm_gk20a *vm = mm->pmu.vm; + int err = 0; + + err = nvgpu_dma_alloc_map(vm, GK20A_PMU_TRACE_BUFSIZE, + &pmu->trace_buf); + if (err != 0) { + nvgpu_err(g, "failed to allocate pmu trace buffer\n"); + } + + return err; +} + +void nvgpu_pmu_debug_deinit(struct gk20a *g, struct nvgpu_pmu *pmu) +{ + struct mm_gk20a *mm = &g->mm; + struct vm_gk20a *vm = mm->pmu.vm; + + if (nvgpu_mem_is_valid(&pmu->trace_buf)) { + nvgpu_dma_unmap_free(vm, &pmu->trace_buf); + } +} diff --git a/drivers/gpu/nvgpu/include/nvgpu/pmu.h b/drivers/gpu/nvgpu/include/nvgpu/pmu.h index 92ca07f0e..4a14fc245 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/pmu.h +++ b/drivers/gpu/nvgpu/include/nvgpu/pmu.h @@ -204,6 +204,8 @@ int nvgpu_pmu_reset(struct gk20a *g); /* PMU debug */ void nvgpu_pmu_dump_falcon_stats(struct nvgpu_pmu *pmu); bool nvgpu_find_hex_in_string(char *strings, struct gk20a *g, u32 *hex_pos); +int nvgpu_pmu_debug_init(struct gk20a *g, struct nvgpu_pmu *pmu); +void nvgpu_pmu_debug_deinit(struct gk20a *g, struct nvgpu_pmu *pmu); struct gk20a *gk20a_from_pmu(struct nvgpu_pmu *pmu);