diff --git a/arch/nvgpu-posix.yaml b/arch/nvgpu-posix.yaml index 2a812b3a8..79268aa16 100644 --- a/arch/nvgpu-posix.yaml +++ b/arch/nvgpu-posix.yaml @@ -32,6 +32,7 @@ all: os/posix/posix-sim.c, os/posix/posix-vgpu.c, os/posix/posix-vidmem.c, + os/posix/fecs_trace_posix.c, os/posix/stubs.c ] headers: diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile index 85a5e8f98..8c272ad99 100644 --- a/drivers/gpu/nvgpu/Makefile +++ b/drivers/gpu/nvgpu/Makefile @@ -60,7 +60,6 @@ nvgpu-y += \ common/gr/subctx.o \ common/gr/zcull.o \ common/gr/gr_config.o \ - common/gr/fecs_trace.o \ common/gr/zbc.o \ common/gr/gr_setup.o \ common/gr/hwpm_map.o \ @@ -185,8 +184,6 @@ nvgpu-y += \ hal/gr/ecc/ecc_gp10b.o \ hal/gr/ecc/ecc_gv11b.o \ hal/gr/ecc/ecc_tu104.o \ - hal/gr/fecs_trace/fecs_trace_gm20b.o \ - hal/gr/fecs_trace/fecs_trace_gv11b.o \ hal/gr/zcull/zcull_gm20b.o \ hal/gr/zcull/zcull_gv11b.o \ hal/gr/ctxsw_prog/ctxsw_prog_gm20b.o \ @@ -429,6 +426,9 @@ nvgpu-$(CONFIG_DEBUG_FS) += \ endif nvgpu-$(CONFIG_GK20A_CTXSW_TRACE) += \ + common/gr/fecs_trace.o \ + hal/gr/fecs_trace/fecs_trace_gm20b.o \ + hal/gr/fecs_trace/fecs_trace_gv11b.o \ os/linux/fecs_trace_linux.o ifeq ($(CONFIG_GK20A_CTXSW_TRACE),y) @@ -472,9 +472,13 @@ nvgpu-$(CONFIG_TEGRA_GR_VIRTUALIZATION) += \ os/linux/vgpu/vgpu_ivc.o \ os/linux/vgpu/vgpu_ivm.o \ os/linux/vgpu/vgpu_linux.o \ - os/linux/vgpu/fecs_trace_vgpu_linux.o \ os/linux/vgpu/gv11b/platform_gv11b_vgpu_tegra.o +ifeq ($(CONFIG_GK20A_CTXSW_TRACE),y) +nvgpu-$(CONFIG_TEGRA_GR_VIRTUALIZATION) += \ + os/linux/vgpu/fecs_trace_vgpu_linux.o +endif + nvgpu-$(CONFIG_COMMON_CLK) += \ os/linux/clk.o diff --git a/drivers/gpu/nvgpu/Makefile.shared.configs b/drivers/gpu/nvgpu/Makefile.shared.configs index a43608459..edb31e643 100644 --- a/drivers/gpu/nvgpu/Makefile.shared.configs +++ b/drivers/gpu/nvgpu/Makefile.shared.configs @@ -50,4 +50,6 @@ NVGPU_DGPU_SUPPORT := 1 NVGPU_COMMON_CFLAGS += -DNVGPU_DGPU_SUPPORT ifeq ($(NV_BUILD_CONFIGURATION_IS_SAFETY),0) +NVGPU_FECS_TRACE_SUPPORT := 1 +NVGPU_COMMON_CFLAGS += -DCONFIG_GK20A_CTXSW_TRACE endif diff --git a/drivers/gpu/nvgpu/Makefile.sources b/drivers/gpu/nvgpu/Makefile.sources index b43a2f85e..21c611257 100644 --- a/drivers/gpu/nvgpu/Makefile.sources +++ b/drivers/gpu/nvgpu/Makefile.sources @@ -43,7 +43,8 @@ srcs += os/posix/nvgpu.c \ os/posix/posix-nvhost.c \ os/posix/posix-vgpu.c \ os/posix/posix-dt.c \ - os/posix/posix-vidmem.c + os/posix/posix-vidmem.c \ + os/posix/fecs_trace_posix.c endif # POSIX sources shared between the POSIX and QNX builds. @@ -116,7 +117,6 @@ srcs += common/sim/sim.c \ common/gr/gr_falcon.c \ common/gr/zcull.c \ common/gr/gr_config.c \ - common/gr/fecs_trace.c \ common/gr/zbc.c \ common/gr/gr_setup.c \ common/gr/hwpm_map.c \ @@ -278,8 +278,6 @@ srcs += common/sim/sim.c \ hal/gr/ecc/ecc_gp10b.c \ hal/gr/ecc/ecc_gv11b.c \ hal/gr/ecc/ecc_tu104.c \ - hal/gr/fecs_trace/fecs_trace_gm20b.c \ - hal/gr/fecs_trace/fecs_trace_gv11b.c \ hal/gr/zcull/zcull_gm20b.c \ hal/gr/zcull/zcull_gv11b.c \ hal/gr/ctxsw_prog/ctxsw_prog_gm20b.c \ @@ -456,6 +454,18 @@ ifeq ($(NVGPU_DEBUGGER),1) srcs += common/debugger.c endif +ifeq ($(NVGPU_FECS_TRACE_SUPPORT),1) +srcs += common/gr/fecs_trace.c \ + hal/gr/fecs_trace/fecs_trace_gm20b.c \ + hal/gr/fecs_trace/fecs_trace_gv11b.c +endif + +ifeq ($(NVGPU_FECS_TRACE_SUPPORT),1) +ifeq ($(IGPU_VIRT_SUPPORT), 1) +srcs += common/vgpu/gr/fecs_trace_vgpu.c +endif +endif + # POSIX file used for unit testing for both qnx and linux ifdef NVGPU_FAULT_INJECTION_ENABLEMENT srcs += os/posix/posix-fault-injection.c @@ -484,7 +494,6 @@ srcs += common/vgpu/init/init_vgpu.c \ common/vgpu/tsg_vgpu.c \ common/vgpu/perf/cyclestats_snapshot_vgpu.c \ common/vgpu/perf/perf_vgpu.c \ - common/vgpu/gr/fecs_trace_vgpu.c \ common/vgpu/mm/mm_vgpu.c \ common/vgpu/mm/vm_vgpu.c \ common/vgpu/gr/gr_vgpu.c \ diff --git a/drivers/gpu/nvgpu/common/gr/fecs_trace.c b/drivers/gpu/nvgpu/common/gr/fecs_trace.c index 10cacc778..9fc6e67b0 100644 --- a/drivers/gpu/nvgpu/common/gr/fecs_trace.c +++ b/drivers/gpu/nvgpu/common/gr/fecs_trace.c @@ -34,8 +34,6 @@ #include #include -#ifdef CONFIG_GK20A_CTXSW_TRACE - static int nvgpu_gr_fecs_trace_periodic_polling(void *arg); int nvgpu_gr_fecs_trace_add_context(struct gk20a *g, u32 context_ptr, @@ -707,5 +705,3 @@ int nvgpu_gr_fecs_trace_unbind_channel(struct gk20a *g, return 0; } - -#endif /* CONFIG_GK20A_CTXSW_TRACE */ diff --git a/drivers/gpu/nvgpu/hal/gr/fecs_trace/fecs_trace_gm20b.c b/drivers/gpu/nvgpu/hal/gr/fecs_trace/fecs_trace_gm20b.c index 8b8ab910e..7b93e211a 100644 --- a/drivers/gpu/nvgpu/hal/gr/fecs_trace/fecs_trace_gm20b.c +++ b/drivers/gpu/nvgpu/hal/gr/fecs_trace/fecs_trace_gm20b.c @@ -30,8 +30,6 @@ #include -#ifdef CONFIG_GK20A_CTXSW_TRACE - int gm20b_fecs_trace_flush(struct gk20a *g) { int err; @@ -70,5 +68,3 @@ u32 gm20b_fecs_trace_get_buffer_full_mailbox_val(void) { return 0x26; } - -#endif /* CONFIG_GK20A_CTXSW_TRACE */ diff --git a/drivers/gpu/nvgpu/hal/gr/fecs_trace/fecs_trace_gv11b.c b/drivers/gpu/nvgpu/hal/gr/fecs_trace/fecs_trace_gv11b.c index d858060c2..908725820 100644 --- a/drivers/gpu/nvgpu/hal/gr/fecs_trace/fecs_trace_gv11b.c +++ b/drivers/gpu/nvgpu/hal/gr/fecs_trace/fecs_trace_gv11b.c @@ -22,11 +22,7 @@ #include "fecs_trace_gv11b.h" -#ifdef CONFIG_GK20A_CTXSW_TRACE - u32 gv11b_fecs_trace_get_buffer_full_mailbox_val(void) { return 0x32; } - -#endif /* CONFIG_GK20A_CTXSW_TRACE */ diff --git a/drivers/gpu/nvgpu/os/linux/fecs_trace_linux.c b/drivers/gpu/nvgpu/os/linux/fecs_trace_linux.c index 066be2bcf..214bcbb53 100644 --- a/drivers/gpu/nvgpu/os/linux/fecs_trace_linux.c +++ b/drivers/gpu/nvgpu/os/linux/fecs_trace_linux.c @@ -547,7 +547,6 @@ int gk20a_ctxsw_dev_mmap(struct file *filp, struct vm_area_struct *vma) return ret; } -#ifdef CONFIG_GK20A_CTXSW_TRACE static int gk20a_ctxsw_init_devs(struct gk20a *g) { struct gk20a_ctxsw_trace *trace = g->ctxsw_trace; @@ -568,11 +567,9 @@ static int gk20a_ctxsw_init_devs(struct gk20a *g) } return 0; } -#endif int gk20a_ctxsw_trace_init(struct gk20a *g) { -#ifdef CONFIG_GK20A_CTXSW_TRACE struct gk20a_ctxsw_trace *trace = g->ctxsw_trace; int err; @@ -605,14 +602,10 @@ fail: nvgpu_kfree(g, trace); g->ctxsw_trace = NULL; return err; -#else - return 0; -#endif } void gk20a_ctxsw_trace_cleanup(struct gk20a *g) { -#ifdef CONFIG_GK20A_CTXSW_TRACE struct gk20a_ctxsw_trace *trace; struct gk20a_ctxsw_dev *dev; int i; @@ -632,7 +625,6 @@ void gk20a_ctxsw_trace_cleanup(struct gk20a *g) g->ctxsw_trace = NULL; g->ops.gr.fecs_trace.deinit(g); -#endif } int nvgpu_gr_fecs_trace_write_entry(struct gk20a *g, @@ -744,7 +736,6 @@ void nvgpu_gr_fecs_trace_wake_up(struct gk20a *g, int vmid) void nvgpu_gr_fecs_trace_add_tsg_reset(struct gk20a *g, struct nvgpu_tsg *tsg) { -#ifdef CONFIG_GK20A_CTXSW_TRACE struct nvgpu_gpu_ctxsw_trace_entry entry = { .vmid = 0, .tag = NVGPU_CTXSW_TAG_ENGINE_RESET, @@ -758,7 +749,7 @@ void nvgpu_gr_fecs_trace_add_tsg_reset(struct gk20a *g, struct nvgpu_tsg *tsg) g->ops.ptimer.read_ptimer(g, &entry.timestamp); nvgpu_gr_fecs_trace_write_entry(g, &entry); nvgpu_gr_fecs_trace_wake_up(g, 0); -#endif + trace_gk20a_channel_reset(~0, tsg->tsgid); } diff --git a/drivers/gpu/nvgpu/os/posix/fecs_trace_posix.c b/drivers/gpu/nvgpu/os/posix/fecs_trace_posix.c new file mode 100644 index 000000000..05bcfc57a --- /dev/null +++ b/drivers/gpu/nvgpu/os/posix/fecs_trace_posix.c @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include + +int vgpu_alloc_user_buffer(struct gk20a *g, void **buf, size_t *size); +void vgpu_fecs_trace_data_update(struct gk20a *g); +void vgpu_get_mmap_user_buffer_info(struct gk20a *g, + void **mmapaddr, size_t *mmapsize); + +int nvgpu_gr_fecs_trace_ring_alloc(struct gk20a *g, + void **buf, size_t *size) +{ + return -EINVAL; +} + +int nvgpu_gr_fecs_trace_ring_free(struct gk20a *g) +{ + return -EINVAL; +} + +void nvgpu_gr_fecs_trace_get_mmap_buffer_info(struct gk20a *g, + void **mmapaddr, size_t *mmapsize) +{ +} + +int nvgpu_gr_fecs_trace_write_entry(struct gk20a *g, + struct nvgpu_gpu_ctxsw_trace_entry *entry) +{ + return -EINVAL; +} + +void nvgpu_gr_fecs_trace_wake_up(struct gk20a *g, int vmid) +{ +} + +void nvgpu_gr_fecs_trace_add_tsg_reset(struct gk20a *g, struct nvgpu_tsg *tsg) +{ +} + +u8 nvgpu_gpu_ctxsw_tags_to_common_tags(u8 tags) +{ + return 0; +} + +int vgpu_alloc_user_buffer(struct gk20a *g, void **buf, size_t *size) +{ + return -EINVAL; +} + +void vgpu_fecs_trace_data_update(struct gk20a *g) +{ +} + +void vgpu_get_mmap_user_buffer_info(struct gk20a *g, + void **mmapaddr, size_t *mmapsize) +{ +}