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 +++++++++++--- 4 files changed, 33 insertions(+), 45 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a') 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 */ -- cgit v1.2.2