From 0dc80244eea4c7e504976d8028a3ddb72ba60b0e Mon Sep 17 00:00:00 2001 From: Sunny He Date: Thu, 22 Jun 2017 16:43:51 -0700 Subject: gpu: nvgpu: Reorganize ltc HAL initialization Reorganize HAL initialization to remove inheritance and construct the gpu_ops struct at compile time. This patch only covers the ltc 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: I1110e301e57b502cf7f97e6739424cb33cc52a69 Signed-off-by: Sunny He Reviewed-on: https://git-master/r/1507564 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gm20b/hal_gm20b.c | 20 +++++++++++++++++--- drivers/gpu/nvgpu/gm20b/ltc_gm20b.c | 26 +++----------------------- drivers/gpu/nvgpu/gm20b/ltc_gm20b.h | 7 +++++-- 3 files changed, 25 insertions(+), 28 deletions(-) (limited to 'drivers/gpu/nvgpu/gm20b') diff --git a/drivers/gpu/nvgpu/gm20b/hal_gm20b.c b/drivers/gpu/nvgpu/gm20b/hal_gm20b.c index 831fd5da..53542702 100644 --- a/drivers/gpu/nvgpu/gm20b/hal_gm20b.c +++ b/drivers/gpu/nvgpu/gm20b/hal_gm20b.c @@ -46,7 +46,22 @@ #define PRIV_SECURITY_DISABLE 0x01 -static struct gpu_ops gm20b_ops = { +static const struct gpu_ops gm20b_ops = { + .ltc = { + .determine_L2_size_bytes = gm20b_determine_L2_size_bytes, + .set_zbc_color_entry = gm20b_ltc_set_zbc_color_entry, + .set_zbc_depth_entry = gm20b_ltc_set_zbc_depth_entry, + .init_cbc = gm20b_ltc_init_cbc, + .init_fs_state = gm20b_ltc_init_fs_state, + .init_comptags = gm20b_ltc_init_comptags, + .cbc_ctrl = gm20b_ltc_cbc_ctrl, + .isr = gm20b_ltc_isr, + .cbc_fix_config = gm20b_ltc_cbc_fix_config, + .flush = gm20b_flush_ltc, +#ifdef CONFIG_DEBUG_FS + .sync_debugfs = gm20b_ltc_sync_debugfs, +#endif + }, .clock_gating = { .slcg_bus_load_gating_prod = gm20b_slcg_bus_load_gating_prod, @@ -189,6 +204,7 @@ int gm20b_init_hal(struct gk20a *g) struct nvgpu_gpu_characteristics *c = &g->gpu_characteristics; u32 val; + gops->ltc = gm20b_ops.ltc; gops->clock_gating = gm20b_ops.clock_gating; gops->securegpccs = false; gops->pmupstate = false; @@ -222,9 +238,7 @@ int gm20b_init_hal(struct gk20a *g) gk20a_init_bus(gops); gm20b_init_mc(gops); gk20a_init_priv_ring(gops); - gm20b_init_ltc(gops); gm20b_init_gr(gops); - gm20b_init_ltc(gops); gm20b_init_fb(gops); gm20b_init_fifo(gops); gm20b_init_ce2(gops); diff --git a/drivers/gpu/nvgpu/gm20b/ltc_gm20b.c b/drivers/gpu/nvgpu/gm20b/ltc_gm20b.c index e4e385fb..5e938141 100644 --- a/drivers/gpu/nvgpu/gm20b/ltc_gm20b.c +++ b/drivers/gpu/nvgpu/gm20b/ltc_gm20b.c @@ -29,7 +29,7 @@ #include "gk20a/ltc_gk20a.h" #include "ltc_gm20b.h" -static int gm20b_ltc_init_comptags(struct gk20a *g, struct gr_gk20a *gr) +int gm20b_ltc_init_comptags(struct gk20a *g, struct gr_gk20a *gr) { /* max memory size (MB) to cover */ u32 max_size = gr->max_comptag_mem; @@ -309,7 +309,7 @@ void gm20b_flush_ltc(struct gk20a *g) } } -static int gm20b_determine_L2_size_bytes(struct gk20a *g) +int gm20b_determine_L2_size_bytes(struct gk20a *g) { u32 lts_per_ltc; u32 ways; @@ -438,7 +438,7 @@ void gm20b_ltc_init_cbc(struct gk20a *g, struct gr_gk20a *gr) } #ifdef CONFIG_DEBUG_FS -static void gm20b_ltc_sync_debugfs(struct gk20a *g) +void gm20b_ltc_sync_debugfs(struct gk20a *g) { u32 reg_f = ltc_ltcs_ltss_tstg_set_mgmt_2_l2_bypass_mode_enabled_f(); @@ -459,23 +459,3 @@ static void gm20b_ltc_sync_debugfs(struct gk20a *g) nvgpu_spinlock_release(&g->debugfs_lock); } #endif - -void gm20b_init_ltc(struct gpu_ops *gops) -{ - /* Gk20a reused ops. */ - gops->ltc.determine_L2_size_bytes = gm20b_determine_L2_size_bytes; - gops->ltc.set_zbc_color_entry = gm20b_ltc_set_zbc_color_entry; - gops->ltc.set_zbc_depth_entry = gm20b_ltc_set_zbc_depth_entry; - gops->ltc.init_cbc = gm20b_ltc_init_cbc; - - /* GM20b specific ops. */ - gops->ltc.init_fs_state = gm20b_ltc_init_fs_state; - gops->ltc.init_comptags = gm20b_ltc_init_comptags; - gops->ltc.cbc_ctrl = gm20b_ltc_cbc_ctrl; - gops->ltc.isr = gm20b_ltc_isr; - gops->ltc.cbc_fix_config = gm20b_ltc_cbc_fix_config; - gops->ltc.flush = gm20b_flush_ltc; -#ifdef CONFIG_DEBUG_FS - gops->ltc.sync_debugfs = gm20b_ltc_sync_debugfs; -#endif -} diff --git a/drivers/gpu/nvgpu/gm20b/ltc_gm20b.h b/drivers/gpu/nvgpu/gm20b/ltc_gm20b.h index 4fe83250..b5661d4e 100644 --- a/drivers/gpu/nvgpu/gm20b/ltc_gm20b.h +++ b/drivers/gpu/nvgpu/gm20b/ltc_gm20b.h @@ -17,6 +17,8 @@ #define _NVHOST_GM20B_LTC struct gpu_ops; +int gm20b_ltc_init_comptags(struct gk20a *g, struct gr_gk20a *gr); +int gm20b_determine_L2_size_bytes(struct gk20a *g); void gm20b_ltc_set_zbc_color_entry(struct gk20a *g, struct zbc_entry *color_val, u32 index); @@ -24,8 +26,9 @@ void gm20b_ltc_set_zbc_depth_entry(struct gk20a *g, struct zbc_entry *depth_val, u32 index); void gm20b_ltc_init_cbc(struct gk20a *g, struct gr_gk20a *gr); - -void gm20b_init_ltc(struct gpu_ops *gops); +#ifdef CONFIG_DEBUG_FS +void gm20b_ltc_sync_debugfs(struct gk20a *g); +#endif void gm20b_ltc_init_fs_state(struct gk20a *g); int gm20b_ltc_cbc_ctrl(struct gk20a *g, enum gk20a_cbc_op op, u32 min, u32 max); -- cgit v1.2.2