From 8478f6356a94651dca1aed8c65df0ca0f0a50016 Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Fri, 14 Apr 2017 13:36:05 -0700 Subject: gpu: nvgpu: Move aggressive_sync_destroy to gk20a Copy aggressive_sync_destroy* to struct gk20a at probe time, and access it from gk20a instead of platform_gk20a. JIRA NVGPU-16 Change-Id: I6a1c04d85580cb62ab9a52bae08a0f99fe7cfef9 Signed-off-by: Terje Bergstrom Reviewed-on: http://git-master/r/1463542 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/driver_common.c | 2 ++ drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 32 +++++++++----------------- drivers/gpu/nvgpu/gk20a/gk20a.h | 3 +++ drivers/gpu/nvgpu/vgpu/vgpu.c | 7 ++++-- 4 files changed, 21 insertions(+), 23 deletions(-) (limited to 'drivers/gpu/nvgpu') diff --git a/drivers/gpu/nvgpu/common/linux/driver_common.c b/drivers/gpu/nvgpu/common/linux/driver_common.c index 10394b22..31cc879c 100644 --- a/drivers/gpu/nvgpu/common/linux/driver_common.c +++ b/drivers/gpu/nvgpu/common/linux/driver_common.c @@ -105,6 +105,8 @@ static void nvgpu_init_pm_vars(struct gk20a *g) g->can_elpg = nvgpu_platform_is_silicon(g) ? platform->can_elpg : false; g->default_pri_timeout = platform->default_pri_timeout; + g->aggressive_sync_destroy = platform->aggressive_sync_destroy; + g->aggressive_sync_destroy_thresh = platform->aggressive_sync_destroy_thresh; /* set default values to aelpg parameters */ g->pmu.aelpg_param[0] = APCTRL_SAMPLING_PERIOD_PG_DEFAULT_US; diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index 90efc658..eafa17fb 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c @@ -81,9 +81,7 @@ static void gk20a_channel_clean_up_jobs(struct channel_gk20a *c, static struct channel_gk20a *allocate_channel(struct fifo_gk20a *f) { struct channel_gk20a *ch = NULL; - struct gk20a_platform *platform; - - platform = gk20a_get_platform(f->g->dev); + struct gk20a *g = f->g; nvgpu_mutex_acquire(&f->free_chs_mutex); if (!nvgpu_list_empty(&f->free_chs)) { @@ -96,10 +94,10 @@ static struct channel_gk20a *allocate_channel(struct fifo_gk20a *f) } nvgpu_mutex_release(&f->free_chs_mutex); - if (platform->aggressive_sync_destroy_thresh && + if (g->aggressive_sync_destroy_thresh && (f->used_channels > - platform->aggressive_sync_destroy_thresh)) - platform->aggressive_sync_destroy = true; + g->aggressive_sync_destroy_thresh)) + g->aggressive_sync_destroy = true; return ch; } @@ -107,7 +105,6 @@ static struct channel_gk20a *allocate_channel(struct fifo_gk20a *f) static void free_channel(struct fifo_gk20a *f, struct channel_gk20a *ch) { - struct gk20a_platform *platform; struct gk20a *g = f->g; trace_gk20a_release_used_channel(ch->hw_chid); @@ -123,12 +120,10 @@ static void free_channel(struct fifo_gk20a *f, * this is fine then because no new channels would be created. */ if (!g->driver_is_dying) { - platform = gk20a_get_platform(g->dev); - - if (platform->aggressive_sync_destroy_thresh && + if (g->aggressive_sync_destroy_thresh && (f->used_channels < - platform->aggressive_sync_destroy_thresh)) - platform->aggressive_sync_destroy = false; + g->aggressive_sync_destroy_thresh)) + g->aggressive_sync_destroy = false; } } @@ -1218,8 +1213,6 @@ int gk20a_channel_alloc_gpfifo(struct channel_gk20a *c, u32 flags) { struct gk20a *g = c->g; - struct device *d = dev_from_gk20a(g); - struct gk20a_platform *platform = gk20a_get_platform(d); struct vm_gk20a *ch_vm; u32 gpfifo_size; int err = 0; @@ -1273,7 +1266,7 @@ int gk20a_channel_alloc_gpfifo(struct channel_gk20a *c, g->ops.fifo.setup_userd(c); - if (!platform->aggressive_sync_destroy_thresh) { + if (!g->aggressive_sync_destroy_thresh) { nvgpu_mutex_acquire(&c->sync_lock); c->sync = gk20a_channel_sync_create(c); if (!c->sync) { @@ -1968,7 +1961,6 @@ static void gk20a_channel_clean_up_jobs(struct channel_gk20a *c, { struct vm_gk20a *vm; struct channel_gk20a_job *job; - struct gk20a_platform *platform; struct gk20a *g; int job_finished = 0; bool watchdog_on = false; @@ -1984,7 +1976,6 @@ static void gk20a_channel_clean_up_jobs(struct channel_gk20a *c, vm = c->vm; g = c->g; - platform = gk20a_get_platform(g->dev); /* * If !clean_all, we're in a condition where watchdog isn't supported @@ -2037,10 +2028,10 @@ static void gk20a_channel_clean_up_jobs(struct channel_gk20a *c, if (c->sync) { c->sync->signal_timeline(c->sync); - if (platform->aggressive_sync_destroy_thresh) { + if (g->aggressive_sync_destroy_thresh) { nvgpu_mutex_acquire(&c->sync_lock); if (atomic_dec_and_test(&c->sync->refcount) && - platform->aggressive_sync_destroy) { + g->aggressive_sync_destroy) { gk20a_channel_sync_destroy(c->sync); c->sync = NULL; } @@ -2243,7 +2234,6 @@ static int gk20a_submit_prepare_syncs(struct channel_gk20a *c, u32 flags) { struct gk20a *g = c->g; - struct gk20a_platform *platform = gk20a_get_platform(g->dev); bool need_sync_fence = false; bool new_sync_created = false; int wait_fence_fd = -1; @@ -2258,7 +2248,7 @@ static int gk20a_submit_prepare_syncs(struct channel_gk20a *c, if (force_need_sync_fence) need_sync_fence = true; - if (platform->aggressive_sync_destroy_thresh) { + if (g->aggressive_sync_destroy_thresh) { nvgpu_mutex_acquire(&c->sync_lock); if (!c->sync) { c->sync = gk20a_channel_sync_create(c); diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index 7c8b4eae..0d1ae9d7 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -996,6 +996,9 @@ struct gk20a { u32 default_pri_timeout; + unsigned int aggressive_sync_destroy_thresh; + bool aggressive_sync_destroy; + u32 emc3d_ratio; #ifdef CONFIG_DEBUG_FS diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.c b/drivers/gpu/nvgpu/vgpu/vgpu.c index cc672b1e..480d80d7 100644 --- a/drivers/gpu/nvgpu/vgpu/vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/vgpu.c @@ -229,7 +229,7 @@ static void vgpu_remove_support(struct gk20a *g) } } -static void vgpu_init_vars(struct gk20a *g) +static void vgpu_init_vars(struct gk20a *g, struct gk20a_platform *platform) { nvgpu_mutex_init(&g->poweroff_lock); g->regs_saved = g->regs; @@ -237,6 +237,9 @@ static void vgpu_init_vars(struct gk20a *g) nvgpu_init_list_node(&g->pending_sema_waits); nvgpu_raw_spinlock_init(&g->pending_sema_waits_lock); + + g->aggressive_sync_destroy = platform->aggressive_sync_destroy; + g->aggressive_sync_destroy_thresh = platform->aggressive_sync_destroy_thresh; } static int vgpu_init_support(struct platform_device *pdev) @@ -595,7 +598,7 @@ int vgpu_probe(struct platform_device *pdev) vgpu_init_support(pdev); - vgpu_init_vars(gk20a); + vgpu_init_vars(gk20a, platform); init_rwsem(&gk20a->busy_lock); -- cgit v1.2.2