From 201ccbfa8503daee9562a22f50a5b626fe4cc6a1 Mon Sep 17 00:00:00 2001 From: seshendra Gadagottu Date: Mon, 16 Oct 2017 12:14:29 -0700 Subject: gpu: nvgpu: gv11b: update dbg ops Updated following hal functions for gv11b and reused them for gv100: perfbuffer_enable perfbuffer_disable These changes are needed because of following reasons: 1. Register offsets for perf_pmasys_* are changed for gv11b/gv100 from gk20a. 2. Updated memory type for perf_pmasys_mem_block_target to sys_ncoh_f(). Bug 200327596 Change-Id: Ia672ac561917c8ed36caea9cc7e74b7fc7ce8188 Signed-off-by: seshendra Gadagottu Reviewed-on: https://git-master.nvidia.com/r/1571074 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/Makefile | 1 + drivers/gpu/nvgpu/gv100/hal_gv100.c | 5 +- drivers/gpu/nvgpu/gv11b/dbg_gpu_gv11b.c | 98 +++++++++++++++++++++++++++++++++ drivers/gpu/nvgpu/gv11b/dbg_gpu_gv11b.h | 28 ++++++++++ drivers/gpu/nvgpu/gv11b/hal_gv11b.c | 5 +- 5 files changed, 133 insertions(+), 4 deletions(-) create mode 100644 drivers/gpu/nvgpu/gv11b/dbg_gpu_gv11b.c create mode 100644 drivers/gpu/nvgpu/gv11b/dbg_gpu_gv11b.h (limited to 'drivers') diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile index bd703d4b..8f1d42da 100644 --- a/drivers/gpu/nvgpu/Makefile +++ b/drivers/gpu/nvgpu/Makefile @@ -7,6 +7,7 @@ nvgpu-y += \ $(nvgpu-t19x)/common/linux/module_t19x.o \ $(nvgpu-t19x)/common/linux/pci_t19x.o \ $(nvgpu-t19x)/gv11b/gv11b.o \ + $(nvgpu-t19x)/gv11b/dbg_gpu_gv11b.o \ $(nvgpu-t19x)/gv11b/mc_gv11b.o \ $(nvgpu-t19x)/gv11b/ltc_gv11b.o \ $(nvgpu-t19x)/gv11b/hal_gv11b.o \ diff --git a/drivers/gpu/nvgpu/gv100/hal_gv100.c b/drivers/gpu/nvgpu/gv100/hal_gv100.c index 7457c185..2ece7be8 100644 --- a/drivers/gpu/nvgpu/gv100/hal_gv100.c +++ b/drivers/gpu/nvgpu/gv100/hal_gv100.c @@ -76,6 +76,7 @@ #include "gp10b/mm_gp10b.h" #include "gp10b/pmu_gp10b.h" +#include "gv11b/dbg_gpu_gv11b.h" #include "gv11b/hal_gv11b.h" #include "gv11b/gr_gv11b.h" #include "gv11b/mc_gv11b.h" @@ -625,8 +626,8 @@ static const struct gpu_ops gv100_ops = { nvgpu_check_and_set_context_reservation, .release_profiler_reservation = nvgpu_release_profiler_reservation, - .perfbuffer_enable = NULL, - .perfbuffer_disable = NULL, + .perfbuffer_enable = gv11b_perfbuf_enable_locked, + .perfbuffer_disable = gv11b_perfbuf_disable_locked, }, .bus = { .init_hw = gk20a_bus_init_hw, diff --git a/drivers/gpu/nvgpu/gv11b/dbg_gpu_gv11b.c b/drivers/gpu/nvgpu/gv11b/dbg_gpu_gv11b.c new file mode 100644 index 00000000..ad50025f --- /dev/null +++ b/drivers/gpu/nvgpu/gv11b/dbg_gpu_gv11b.c @@ -0,0 +1,98 @@ +/* + * Tegra GV11B GPU Debugger/Profiler Driver + * + * Copyright (c) 2017, 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"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include + +#include +#include "gk20a/gk20a.h" +#include + +int gv11b_perfbuf_enable_locked(struct gk20a *g, u64 offset, u32 size) +{ + struct mm_gk20a *mm = &g->mm; + u32 virt_addr_lo; + u32 virt_addr_hi; + u32 inst_pa_page; + int err; + + gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg, ""); + err = gk20a_busy(g); + if (err) { + nvgpu_err(g, "failed to poweron"); + return err; + } + + err = gk20a_alloc_inst_block(g, &mm->perfbuf.inst_block); + if (err) + return err; + + g->ops.mm.init_inst_block(&mm->perfbuf.inst_block, mm->perfbuf.vm, 0); + + virt_addr_lo = u64_lo32(offset); + virt_addr_hi = u64_hi32(offset); + + gk20a_writel(g, perf_pmasys_outbase_r(), virt_addr_lo); + gk20a_writel(g, perf_pmasys_outbaseupper_r(), + perf_pmasys_outbaseupper_ptr_f(virt_addr_hi)); + gk20a_writel(g, perf_pmasys_outsize_r(), size); + + /* this field is aligned to 4K */ + inst_pa_page = gk20a_mm_inst_block_addr(g, + &mm->perfbuf.inst_block) >> 12; + + gk20a_writel(g, perf_pmasys_mem_block_r(), + perf_pmasys_mem_block_base_f(inst_pa_page) | + perf_pmasys_mem_block_valid_true_f() | + perf_pmasys_mem_block_target_sys_ncoh_f()); + + gk20a_idle(g); + return 0; +} + +/* must be called with dbg_sessions_lock held */ +int gv11b_perfbuf_disable_locked(struct gk20a *g) +{ + int err; + + gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg, ""); + err = gk20a_busy(g); + if (err) { + nvgpu_err(g, "failed to poweron"); + return err; + } + + gk20a_writel(g, perf_pmasys_outbase_r(), 0); + gk20a_writel(g, perf_pmasys_outbaseupper_r(), + perf_pmasys_outbaseupper_ptr_f(0)); + gk20a_writel(g, perf_pmasys_outsize_r(), 0); + + gk20a_writel(g, perf_pmasys_mem_block_r(), + perf_pmasys_mem_block_base_f(0) | + perf_pmasys_mem_block_valid_false_f() | + perf_pmasys_mem_block_target_f(0)); + + gk20a_idle(g); + + return 0; +} diff --git a/drivers/gpu/nvgpu/gv11b/dbg_gpu_gv11b.h b/drivers/gpu/nvgpu/gv11b/dbg_gpu_gv11b.h new file mode 100644 index 00000000..88771a49 --- /dev/null +++ b/drivers/gpu/nvgpu/gv11b/dbg_gpu_gv11b.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2016-2017, 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"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#ifndef DBG_GPU_GV11B_H +#define DBG_GPU_GV11B_H + +int gv11b_perfbuf_enable_locked(struct gk20a *g, u64 offset, u32 size); +int gv11b_perfbuf_disable_locked(struct gk20a *g); + +#endif /* DBG_GPU_GV11B_H */ diff --git a/drivers/gpu/nvgpu/gv11b/hal_gv11b.c b/drivers/gpu/nvgpu/gv11b/hal_gv11b.c index 4241145a..e7e2be54 100644 --- a/drivers/gpu/nvgpu/gv11b/hal_gv11b.c +++ b/drivers/gpu/nvgpu/gv11b/hal_gv11b.c @@ -66,6 +66,7 @@ #include "gp106/pmu_gp106.h" #include "gp106/acr_gp106.h" +#include "dbg_gpu_gv11b.h" #include "hal_gv11b.h" #include "gr_gv11b.h" #include "mc_gv11b.h" @@ -633,8 +634,8 @@ static const struct gpu_ops gv11b_ops = { nvgpu_check_and_set_context_reservation, .release_profiler_reservation = nvgpu_release_profiler_reservation, - .perfbuffer_enable = NULL, - .perfbuffer_disable = NULL, + .perfbuffer_enable = gv11b_perfbuf_enable_locked, + .perfbuffer_disable = gv11b_perfbuf_disable_locked, }, .bus = { .init_hw = gk20a_bus_init_hw, -- cgit v1.2.2