From 9d37d8b78c2dac7fa480493d1ab67b95290b87f1 Mon Sep 17 00:00:00 2001 From: Sunny He Date: Wed, 26 Jul 2017 11:13:15 -0700 Subject: gpu: nvgpu: Reorg fecs_trace HAL initialization Reorganize HAL initialization to remove inheritance and construct the gpu_ops struct at compile time. This patch only covers the fecs_trace sub-module of the gpu_ops struct. Perform HAL function assignments in hal_gxxxx.c through the population of a chip-specific copy of gpu_ops. Jira NVGPU-74 Change-Id: I84485ad64997270c6a0fce3c95dc9ceb0094cf6c Signed-off-by: Sunny He Reviewed-on: https://git-master.nvidia.com/r/1527419 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/ctxsw_trace_gk20a.c | 13 +++------ drivers/gpu/nvgpu/gk20a/ctxsw_trace_gk20a.h | 4 ++- drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c | 41 +++++++---------------------- drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.h | 20 +++++++++++--- drivers/gpu/nvgpu/gp106/hal_gp106.c | 22 +++++++++++++++- drivers/gpu/nvgpu/gp10b/fecs_trace_gp10b.c | 12 +-------- drivers/gpu/nvgpu/gp10b/fecs_trace_gp10b.h | 4 +-- drivers/gpu/nvgpu/gp10b/hal_gp10b.c | 22 +++++++++++++++- 8 files changed, 78 insertions(+), 60 deletions(-) diff --git a/drivers/gpu/nvgpu/gk20a/ctxsw_trace_gk20a.c b/drivers/gpu/nvgpu/gk20a/ctxsw_trace_gk20a.c index f3866d6a..cc05ceff 100644 --- a/drivers/gpu/nvgpu/gk20a/ctxsw_trace_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/ctxsw_trace_gk20a.c @@ -170,7 +170,7 @@ static int gk20a_ctxsw_dev_alloc_buffer(struct gk20a_ctxsw_dev *dev, return 0; } -static int gk20a_ctxsw_dev_ring_alloc(struct gk20a *g, +int gk20a_ctxsw_dev_ring_alloc(struct gk20a *g, void **buf, size_t *size) { struct nvgpu_ctxsw_ring_header *hdr; @@ -194,7 +194,7 @@ static int gk20a_ctxsw_dev_ring_alloc(struct gk20a *g, return 0; } -static int gk20a_ctxsw_dev_ring_free(struct gk20a *g) +int gk20a_ctxsw_dev_ring_free(struct gk20a *g) { struct gk20a_ctxsw_dev *dev = &g->ctxsw_trace->devs[0]; @@ -457,7 +457,7 @@ static struct vm_operations_struct gk20a_ctxsw_dev_vma_ops = { .close = gk20a_ctxsw_dev_vma_close, }; -static int gk20a_ctxsw_dev_mmap_buffer(struct gk20a *g, +int gk20a_ctxsw_dev_mmap_buffer(struct gk20a *g, struct vm_area_struct *vma) { return remap_vmalloc_range(vma, g->ctxsw_trace->devs[0].hdr, 0); @@ -715,10 +715,3 @@ void gk20a_ctxsw_trace_tsg_reset(struct gk20a *g, struct tsg_gk20a *tsg) #endif trace_gk20a_channel_reset(~0, tsg->tsgid); } - -void gk20a_ctxsw_trace_init_ops(struct gpu_ops *ops) -{ - ops->fecs_trace.alloc_user_buffer = gk20a_ctxsw_dev_ring_alloc; - ops->fecs_trace.free_user_buffer = gk20a_ctxsw_dev_ring_free; - ops->fecs_trace.mmap_user_buffer = gk20a_ctxsw_dev_mmap_buffer; -} diff --git a/drivers/gpu/nvgpu/gk20a/ctxsw_trace_gk20a.h b/drivers/gpu/nvgpu/gk20a/ctxsw_trace_gk20a.h index 5262538a..887fe415 100644 --- a/drivers/gpu/nvgpu/gk20a/ctxsw_trace_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/ctxsw_trace_gk20a.h @@ -35,12 +35,14 @@ long gk20a_ctxsw_dev_ioctl(struct file *filp, ssize_t gk20a_ctxsw_dev_read(struct file *, char __user *, size_t, loff_t *); unsigned int gk20a_ctxsw_dev_poll(struct file *, struct poll_table_struct *); int gk20a_ctxsw_dev_mmap(struct file *, struct vm_area_struct *); +int gk20a_ctxsw_dev_ring_alloc(struct gk20a *g, void **buf, size_t *size); +int gk20a_ctxsw_dev_ring_free(struct gk20a *g); +int gk20a_ctxsw_dev_mmap_buffer(struct gk20a *g, struct vm_area_struct *vma); int gk20a_ctxsw_trace_init(struct gk20a *); void gk20a_ctxsw_trace_cleanup(struct gk20a *); int gk20a_ctxsw_trace_write(struct gk20a *, struct nvgpu_ctxsw_trace_entry *); void gk20a_ctxsw_trace_wake_up(struct gk20a *g, int vmid); -void gk20a_ctxsw_trace_init_ops(struct gpu_ops *ops); void gk20a_ctxsw_trace_channel_reset(struct gk20a *g, struct channel_gk20a *ch); void gk20a_ctxsw_trace_tsg_reset(struct gk20a *g, struct tsg_gk20a *tsg); diff --git a/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c b/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c index 0b26f657..84bf20b8 100644 --- a/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c @@ -327,7 +327,7 @@ static int gk20a_fecs_trace_ring_read(struct gk20a *g, int index) return 0; } -static int gk20a_fecs_trace_poll(struct gk20a *g) +int gk20a_fecs_trace_poll(struct gk20a *g) { struct gk20a_fecs_trace *trace = g->fecs_trace; @@ -566,7 +566,7 @@ static inline void gk20a_fecs_trace_debugfs_cleanup(struct gk20a *g) #endif /* CONFIG_DEBUG_FS */ -static int gk20a_fecs_trace_init(struct gk20a *g) +int gk20a_fecs_trace_init(struct gk20a *g) { struct gk20a_fecs_trace *trace; int err; @@ -610,7 +610,7 @@ clean: return err; } -static int gk20a_fecs_trace_bind_channel(struct gk20a *g, +int gk20a_fecs_trace_bind_channel(struct gk20a *g, struct channel_gk20a *ch) { /* @@ -678,7 +678,7 @@ static int gk20a_fecs_trace_bind_channel(struct gk20a *g, return 0; } -static int gk20a_fecs_trace_unbind_channel(struct gk20a *g, struct channel_gk20a *ch) +int gk20a_fecs_trace_unbind_channel(struct gk20a *g, struct channel_gk20a *ch) { u32 context_ptr = gk20a_fecs_trace_fecs_context_ptr(g, ch); @@ -694,7 +694,7 @@ static int gk20a_fecs_trace_unbind_channel(struct gk20a *g, struct channel_gk20a return 0; } -static int gk20a_fecs_trace_reset(struct gk20a *g) +int gk20a_fecs_trace_reset(struct gk20a *g) { gk20a_dbg(gpu_dbg_fn|gpu_dbg_ctxsw, ""); @@ -705,7 +705,7 @@ static int gk20a_fecs_trace_reset(struct gk20a *g) return gk20a_fecs_trace_set_read_index(g, 0); } -static int gk20a_fecs_trace_deinit(struct gk20a *g) +int gk20a_fecs_trace_deinit(struct gk20a *g) { struct gk20a_fecs_trace *trace = g->fecs_trace; @@ -722,7 +722,7 @@ static int gk20a_fecs_trace_deinit(struct gk20a *g) return 0; } -static int gk20a_gr_max_entries(struct gk20a *g, +int gk20a_gr_max_entries(struct gk20a *g, struct nvgpu_ctxsw_trace_filter *filter) { int n; @@ -736,7 +736,7 @@ static int gk20a_gr_max_entries(struct gk20a *g, return n * GK20A_FECS_TRACE_NUM_RECORDS; } -static int gk20a_fecs_trace_enable(struct gk20a *g) +int gk20a_fecs_trace_enable(struct gk20a *g) { struct gk20a_fecs_trace *trace = g->fecs_trace; int write; @@ -765,7 +765,7 @@ static int gk20a_fecs_trace_enable(struct gk20a *g) return 0; } -static int gk20a_fecs_trace_disable(struct gk20a *g) +int gk20a_fecs_trace_disable(struct gk20a *g) { struct gk20a_fecs_trace *trace = g->fecs_trace; @@ -775,31 +775,10 @@ static int gk20a_fecs_trace_disable(struct gk20a *g) return -EPERM; } -static bool gk20a_fecs_trace_is_enabled(struct gk20a *g) +bool gk20a_fecs_trace_is_enabled(struct gk20a *g) { struct gk20a_fecs_trace *trace = g->fecs_trace; return (trace && nvgpu_thread_is_running(&trace->poll_task)); } - - -void gk20a_init_fecs_trace_ops(struct gpu_ops *ops) -{ - gk20a_ctxsw_trace_init_ops(ops); - ops->fecs_trace.init = gk20a_fecs_trace_init; - ops->fecs_trace.deinit = gk20a_fecs_trace_deinit; - ops->fecs_trace.enable = gk20a_fecs_trace_enable; - ops->fecs_trace.disable = gk20a_fecs_trace_disable; - ops->fecs_trace.is_enabled = gk20a_fecs_trace_is_enabled; - ops->fecs_trace.reset = gk20a_fecs_trace_reset; - ops->fecs_trace.flush = NULL; - ops->fecs_trace.poll = gk20a_fecs_trace_poll; - ops->fecs_trace.bind_channel = gk20a_fecs_trace_bind_channel; - ops->fecs_trace.unbind_channel = gk20a_fecs_trace_unbind_channel; - ops->fecs_trace.max_entries = gk20a_gr_max_entries; -} -#else -void gk20a_init_fecs_trace_ops(struct gpu_ops *ops) -{ -} #endif /* CONFIG_GK20A_CTXSW_TRACE */ diff --git a/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.h b/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.h index 4979d6c6..454a33e8 100644 --- a/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2016-2017, 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, @@ -14,7 +14,21 @@ #ifndef __FECS_TRACE_GK20A_H #define __FECS_TRACE_GK20A_H -struct gpu_ops; -void gk20a_init_fecs_trace_ops(struct gpu_ops *ops); +struct gk20a; +struct channel_gk20a; +struct nvgpu_ctxsw_trace_filter; + +int gk20a_fecs_trace_poll(struct gk20a *g); +int gk20a_fecs_trace_init(struct gk20a *g); +int gk20a_fecs_trace_bind_channel(struct gk20a *g, + struct channel_gk20a *ch); +int gk20a_fecs_trace_unbind_channel(struct gk20a *g, struct channel_gk20a *ch); +int gk20a_fecs_trace_reset(struct gk20a *g); +int gk20a_fecs_trace_deinit(struct gk20a *g); +int gk20a_gr_max_entries(struct gk20a *g, + struct nvgpu_ctxsw_trace_filter *filter); +int gk20a_fecs_trace_enable(struct gk20a *g); +int gk20a_fecs_trace_disable(struct gk20a *g); +bool gk20a_fecs_trace_is_enabled(struct gk20a *g); #endif /* __FECS_TRACE_GK20A_H */ diff --git a/drivers/gpu/nvgpu/gp106/hal_gp106.c b/drivers/gpu/nvgpu/gp106/hal_gp106.c index 763dab44..dd162109 100644 --- a/drivers/gpu/nvgpu/gp106/hal_gp106.c +++ b/drivers/gpu/nvgpu/gp106/hal_gp106.c @@ -15,6 +15,8 @@ #include "gk20a/gk20a.h" #include "gk20a/fifo_gk20a.h" +#include "gk20a/ctxsw_trace_gk20a.h" +#include "gk20a/fecs_trace_gk20a.h" #include "gk20a/dbg_gpu_gk20a.h" #include "gk20a/css_gr_gk20a.h" #include "gk20a/bus_gk20a.h" @@ -317,6 +319,24 @@ static const struct gpu_ops gp106_ops = { .get_netlist_name = gr_gp106_get_netlist_name, .is_fw_defined = gr_gp106_is_firmware_defined, }, +#ifdef CONFIG_GK20A_CTXSW_TRACE + .fecs_trace = { + .alloc_user_buffer = gk20a_ctxsw_dev_ring_alloc, + .free_user_buffer = gk20a_ctxsw_dev_ring_free, + .mmap_user_buffer = gk20a_ctxsw_dev_mmap_buffer, + .init = gk20a_fecs_trace_init, + .deinit = gk20a_fecs_trace_deinit, + .enable = gk20a_fecs_trace_enable, + .disable = gk20a_fecs_trace_disable, + .is_enabled = gk20a_fecs_trace_is_enabled, + .reset = gk20a_fecs_trace_reset, + .flush = gp10b_fecs_trace_flush, + .poll = gk20a_fecs_trace_poll, + .bind_channel = gk20a_fecs_trace_bind_channel, + .unbind_channel = gk20a_fecs_trace_unbind_channel, + .max_entries = gk20a_gr_max_entries, + }, +#endif /* CONFIG_GK20A_CTXSW_TRACE */ .mc = { .intr_enable = mc_gp10b_intr_enable, .intr_unit_config = mc_gp10b_intr_unit_config, @@ -408,6 +428,7 @@ int gp106_init_hal(struct gk20a *g) gops->clock_gating = gp106_ops.clock_gating; gops->fifo = gp106_ops.fifo; gops->gr_ctx = gp106_ops.gr_ctx; + gops->fecs_trace = gp106_ops.fecs_trace; gops->mc = gp106_ops.mc; gops->debug = gp106_ops.debug; gops->dbg_session_ops = gp106_ops.dbg_session_ops; @@ -433,7 +454,6 @@ int gp106_init_hal(struct gk20a *g) g->bootstrap_owner = LSF_FALCON_ID_SEC2; gp106_init_gr(g); - gp10b_init_fecs_trace_ops(gops); gp106_init_fb(gops); gp106_init_mm(gops); gp106_init_pmu_ops(g); diff --git a/drivers/gpu/nvgpu/gp10b/fecs_trace_gp10b.c b/drivers/gpu/nvgpu/gp10b/fecs_trace_gp10b.c index 723da1a2..bec40512 100644 --- a/drivers/gpu/nvgpu/gp10b/fecs_trace_gp10b.c +++ b/drivers/gpu/nvgpu/gp10b/fecs_trace_gp10b.c @@ -22,7 +22,7 @@ #include #ifdef CONFIG_GK20A_CTXSW_TRACE -static int gp10b_fecs_trace_flush(struct gk20a *g) +int gp10b_fecs_trace_flush(struct gk20a *g) { struct fecs_method_op_gk20a op = { .mailbox = { .id = 0, .data = 0, @@ -43,14 +43,4 @@ static int gp10b_fecs_trace_flush(struct gk20a *g) return err; } - -void gp10b_init_fecs_trace_ops(struct gpu_ops *ops) -{ - gk20a_init_fecs_trace_ops(ops); - ops->fecs_trace.flush = gp10b_fecs_trace_flush; -} -#else -void gp10b_init_fecs_trace_ops(struct gpu_ops *ops) -{ -} #endif /* CONFIG_GK20A_CTXSW_TRACE */ diff --git a/drivers/gpu/nvgpu/gp10b/fecs_trace_gp10b.h b/drivers/gpu/nvgpu/gp10b/fecs_trace_gp10b.h index 656bc551..43ecb6fc 100644 --- a/drivers/gpu/nvgpu/gp10b/fecs_trace_gp10b.h +++ b/drivers/gpu/nvgpu/gp10b/fecs_trace_gp10b.h @@ -16,8 +16,8 @@ #ifndef _NVGPU_FECS_TRACE_GP10B_H_ #define _NVGPU_FECS_TRACE_GP10B_H_ -struct gpu_ops; +struct gk20a; -void gp10b_init_fecs_trace_ops(struct gpu_ops *); +int gp10b_fecs_trace_flush(struct gk20a *g); #endif diff --git a/drivers/gpu/nvgpu/gp10b/hal_gp10b.c b/drivers/gpu/nvgpu/gp10b/hal_gp10b.c index 80018910..1574ac56 100644 --- a/drivers/gpu/nvgpu/gp10b/hal_gp10b.c +++ b/drivers/gpu/nvgpu/gp10b/hal_gp10b.c @@ -15,6 +15,8 @@ #include "gk20a/gk20a.h" #include "gk20a/fifo_gk20a.h" +#include "gk20a/ctxsw_trace_gk20a.h" +#include "gk20a/fecs_trace_gk20a.h" #include "gk20a/dbg_gpu_gk20a.h" #include "gk20a/css_gr_gk20a.h" #include "gk20a/bus_gk20a.h" @@ -283,6 +285,24 @@ static const struct gpu_ops gp10b_ops = { .get_netlist_name = gr_gp10b_get_netlist_name, .is_fw_defined = gr_gp10b_is_firmware_defined, }, +#ifdef CONFIG_GK20A_CTXSW_TRACE + .fecs_trace = { + .alloc_user_buffer = gk20a_ctxsw_dev_ring_alloc, + .free_user_buffer = gk20a_ctxsw_dev_ring_free, + .mmap_user_buffer = gk20a_ctxsw_dev_mmap_buffer, + .init = gk20a_fecs_trace_init, + .deinit = gk20a_fecs_trace_deinit, + .enable = gk20a_fecs_trace_enable, + .disable = gk20a_fecs_trace_disable, + .is_enabled = gk20a_fecs_trace_is_enabled, + .reset = gk20a_fecs_trace_reset, + .flush = gp10b_fecs_trace_flush, + .poll = gk20a_fecs_trace_poll, + .bind_channel = gk20a_fecs_trace_bind_channel, + .unbind_channel = gk20a_fecs_trace_unbind_channel, + .max_entries = gk20a_gr_max_entries, + }, +#endif /* CONFIG_GK20A_CTXSW_TRACE */ .mc = { .intr_enable = mc_gp10b_intr_enable, .intr_unit_config = mc_gp10b_intr_unit_config, @@ -357,6 +377,7 @@ int gp10b_init_hal(struct gk20a *g) gops->clock_gating = gp10b_ops.clock_gating; gops->fifo = gp10b_ops.fifo; gops->gr_ctx = gp10b_ops.gr_ctx; + gops->fecs_trace = gp10b_ops.fecs_trace; gops->mc = gp10b_ops.mc; gops->debug = gp10b_ops.debug; gops->dbg_session_ops = gp10b_ops.dbg_session_ops; @@ -416,7 +437,6 @@ int gp10b_init_hal(struct gk20a *g) g->bootstrap_owner = LSF_BOOTSTRAP_OWNER_DEFAULT; gp10b_init_gr(g); - gp10b_init_fecs_trace_ops(gops); gp10b_init_fb(gops); gp10b_init_mm(gops); gp10b_init_pmu_ops(g); -- cgit v1.2.2