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);