From a30924340f879db1f2857e066b919eeecf03c693 Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Fri, 14 Apr 2017 15:54:49 -0700 Subject: gpu: nvgpu: Add new flag support_pmu to gk20a Add new flag support_pmu to struct gk20a at probe time, and access it from gk20a instead of support_gk20a_pmu() which depends on struct device *. JIRA NVGPU-16 Change-Id: I721f1a532e949c98346086abdc2630a8df6eba7b Signed-off-by: Terje Bergstrom Reviewed-on: http://git-master/r/1463546 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/driver_common.c | 1 + drivers/gpu/nvgpu/gk20a/fifo_gk20a.c | 8 ++++---- drivers/gpu/nvgpu/gk20a/gk20a.h | 2 ++ drivers/gpu/nvgpu/gk20a/gr_gk20a.c | 4 ++-- drivers/gpu/nvgpu/gk20a/gr_gk20a.h | 4 ++-- drivers/gpu/nvgpu/gk20a/pmu_gk20a.c | 12 ++++++------ drivers/gpu/nvgpu/lpwr/lpwr.c | 4 ++-- 7 files changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/nvgpu/common/linux/driver_common.c b/drivers/gpu/nvgpu/common/linux/driver_common.c index 4919b03f..34bd2062 100644 --- a/drivers/gpu/nvgpu/common/linux/driver_common.c +++ b/drivers/gpu/nvgpu/common/linux/driver_common.c @@ -109,6 +109,7 @@ static void nvgpu_init_pm_vars(struct gk20a *g) g->aggressive_sync_destroy_thresh = platform->aggressive_sync_destroy_thresh; g->has_syncpoints = platform->has_syncpoints; g->ptimer_src_freq = platform->ptimer_src_freq; + g->support_pmu = support_gk20a_pmu(g->dev); /* set default values to aelpg parameters */ g->pmu.aelpg_param[0] = APCTRL_SAMPLING_PERIOD_PG_DEFAULT_US; diff --git a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c index b96adc5a..4129e407 100644 --- a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c @@ -1231,7 +1231,7 @@ void gk20a_fifo_reset_engine(struct gk20a *g, u32 engine_id) nvgpu_err(g, "unsupported engine_id %d", engine_id); if (engine_enum == ENGINE_GR_GK20A) { - if (support_gk20a_pmu(g->dev) && g->elpg_enabled) + if (g->support_pmu && g->elpg_enabled) gk20a_pmu_disable_elpg(g); /* resetting engine will alter read/write index. * need to flush circular buffer before re-enabling FECS. @@ -1244,7 +1244,7 @@ void gk20a_fifo_reset_engine(struct gk20a *g, u32 engine_id) /* resetting engine using mc_enable_r() is not enough, we do full init sequence */ gk20a_gr_reset(g); - if (support_gk20a_pmu(g->dev) && g->elpg_enabled) + if (g->support_pmu && g->elpg_enabled) gk20a_pmu_enable_elpg(g); } if ((engine_enum == ENGINE_GRCE_GK20A) || @@ -1479,7 +1479,7 @@ static bool gk20a_fifo_handle_mmu_fault( g->fifo.deferred_reset_pending = false; /* Disable power management */ - if (support_gk20a_pmu(g->dev) && g->elpg_enabled) + if (g->support_pmu && g->elpg_enabled) gk20a_pmu_disable_elpg(g); if (g->ops.clock_gating.slcg_gr_load_gating_prod) g->ops.clock_gating.slcg_gr_load_gating_prod(g, @@ -1678,7 +1678,7 @@ static bool gk20a_fifo_handle_mmu_fault( gr_gpfifo_ctl_semaphore_access_enabled_f()); /* It is safe to enable ELPG again. */ - if (support_gk20a_pmu(g->dev) && g->elpg_enabled) + if (g->support_pmu && g->elpg_enabled) gk20a_pmu_enable_elpg(g); return verbose; } diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index 6c846251..71ff8d3e 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -1005,6 +1005,8 @@ struct gk20a { /* Debugfs knob for forcing syncpt support off in runtime. */ u32 disable_syncpoints; + bool support_pmu; + u32 emc3d_ratio; #ifdef CONFIG_DEBUG_FS diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c index 57cd266d..ac03c1e5 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c @@ -3231,7 +3231,7 @@ int gk20a_alloc_obj_ctx(struct channel_gk20a *c, u32 lockboost_mask; u32 lockboost; - if (support_gk20a_pmu(g->dev)) { + if (g->support_pmu) { err = gk20a_pmu_disable_elpg(g); if (err) { nvgpu_err(g, @@ -3281,7 +3281,7 @@ int gk20a_alloc_obj_ctx(struct channel_gk20a *c, args->flags |= NVGPU_ALLOC_OBJ_FLAGS_LOCKBOOST_ZERO; - if (support_gk20a_pmu(g->dev)) + if (g->support_pmu) gk20a_pmu_enable_elpg(g); } diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.h b/drivers/gpu/nvgpu/gk20a/gr_gk20a.h index 24bfb3b7..06ce96e7 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.h @@ -544,14 +544,14 @@ void gk20a_gr_clear_sm_hww(struct gk20a *g, #define gr_gk20a_elpg_protected_call(g, func) \ ({ \ int err = 0; \ - if (support_gk20a_pmu(g->dev) && g->elpg_enabled) {\ + if (g->support_pmu && g->elpg_enabled) {\ err = gk20a_pmu_disable_elpg(g); \ if (err) \ gk20a_pmu_enable_elpg(g); \ } \ if (!err) { \ err = func; \ - if (support_gk20a_pmu(g->dev) && g->elpg_enabled) \ + if (g->support_pmu && g->elpg_enabled) \ gk20a_pmu_enable_elpg(g); \ } \ err; \ diff --git a/drivers/gpu/nvgpu/gk20a/pmu_gk20a.c b/drivers/gpu/nvgpu/gk20a/pmu_gk20a.c index 98513511..26ce66f1 100644 --- a/drivers/gpu/nvgpu/gk20a/pmu_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/pmu_gk20a.c @@ -3548,7 +3548,7 @@ int gk20a_init_pmu_support(struct gk20a *g) if (err) return err; - if (support_gk20a_pmu(g->dev)) { + if (g->support_pmu) { err = gk20a_init_pmu_setup_sw(g); if (err) return err; @@ -4945,7 +4945,7 @@ int gk20a_pmu_pg_global_enable(struct gk20a *g, u32 enable_pg) if (g->ops.pmu.pmu_lpwr_enable_pg) status = g->ops.pmu.pmu_lpwr_enable_pg(g, true); - } else if (support_gk20a_pmu(g->dev)) + } else if (g->support_pmu) status = gk20a_pmu_enable_elpg(g); } else if (enable_pg == false) { if (g->ops.pmu.pmu_pg_engines_feature_list && @@ -4955,7 +4955,7 @@ int gk20a_pmu_pg_global_enable(struct gk20a *g, u32 enable_pg) if (g->ops.pmu.pmu_lpwr_disable_pg) status = g->ops.pmu.pmu_lpwr_disable_pg(g, true); - } else if (support_gk20a_pmu(g->dev)) + } else if (g->support_pmu) status = gk20a_pmu_disable_elpg(g); } @@ -5008,7 +5008,7 @@ int gk20a_pmu_enable_elpg(struct gk20a *g) gk20a_dbg_fn(""); - if (!support_gk20a_pmu(g->dev)) + if (!g->support_pmu) return ret; nvgpu_mutex_acquire(&pmu->elpg_mutex); @@ -5070,7 +5070,7 @@ int gk20a_pmu_disable_elpg(struct gk20a *g) if (g->ops.pmu.pmu_pg_supported_engines_list) pg_engine_id_list = g->ops.pmu.pmu_pg_supported_engines_list(g); - if (!support_gk20a_pmu(g->dev)) + if (!g->support_pmu) return ret; nvgpu_mutex_acquire(&pmu->elpg_mutex); @@ -5188,7 +5188,7 @@ int gk20a_pmu_destroy(struct gk20a *g) gk20a_dbg_fn(""); - if (!support_gk20a_pmu(g->dev)) + if (!g->support_pmu) return 0; /* make sure the pending operations are finished before we continue */ diff --git a/drivers/gpu/nvgpu/lpwr/lpwr.c b/drivers/gpu/nvgpu/lpwr/lpwr.c index 9ff7c2a7..1f15d512 100644 --- a/drivers/gpu/nvgpu/lpwr/lpwr.c +++ b/drivers/gpu/nvgpu/lpwr/lpwr.c @@ -363,7 +363,7 @@ int nvgpu_lpwr_enable_pg(struct gk20a *g, bool pstate_lock) is_rppg_supported = nvgpu_lpwr_is_rppg_supported(g, present_pstate); if (is_rppg_supported) { - if (support_gk20a_pmu(g->dev) && g->elpg_enabled) + if (g->support_pmu && g->elpg_enabled) status = gk20a_pmu_enable_elpg(g); } @@ -393,7 +393,7 @@ int nvgpu_lpwr_disable_pg(struct gk20a *g, bool pstate_lock) is_rppg_supported = nvgpu_lpwr_is_rppg_supported(g, present_pstate); if (is_rppg_supported) { - if (support_gk20a_pmu(g->dev) && g->elpg_enabled) { + if (g->support_pmu && g->elpg_enabled) { status = gk20a_pmu_disable_elpg(g); if (status) goto exit_unlock; -- cgit v1.2.2