From 4f56c88febf0cc8630ad75f184ada11a9d4894ed Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Wed, 27 Sep 2017 12:59:34 -0700 Subject: gpu: nvgpu: Move gk20a->busy_lock to os_linux gk20a->busy_lock is a Linux specific rw_semaphore used only by Linux code. Move it to os_linux. JIRA NVGPU-259 Change-Id: I220a8a080a5050732683b875d3c1d0539ba0f40e Signed-off-by: Terje Bergstrom Reviewed-on: https://git-master.nvidia.com/r/1569695 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/driver_common.c | 2 +- drivers/gpu/nvgpu/common/linux/module.c | 19 +++++++++++-------- drivers/gpu/nvgpu/common/linux/os_linux.h | 2 ++ drivers/gpu/nvgpu/gk20a/gk20a.h | 1 - drivers/gpu/nvgpu/vgpu/vgpu.c | 2 +- 5 files changed, 15 insertions(+), 11 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 5f2961f4..b82e3784 100644 --- a/drivers/gpu/nvgpu/common/linux/driver_common.c +++ b/drivers/gpu/nvgpu/common/linux/driver_common.c @@ -42,7 +42,7 @@ static void nvgpu_init_vars(struct gk20a *g) init_waitqueue_head(&l->sw_irq_nonstall_last_handled_wq); gk20a_init_gr(g); - init_rwsem(&g->busy_lock); + init_rwsem(&l->busy_lock); init_rwsem(&g->deterministic_busy); nvgpu_spinlock_init(&g->mc_enable_lock); diff --git a/drivers/gpu/nvgpu/common/linux/module.c b/drivers/gpu/nvgpu/common/linux/module.c index c474f36a..dcff089b 100644 --- a/drivers/gpu/nvgpu/common/linux/module.c +++ b/drivers/gpu/nvgpu/common/linux/module.c @@ -63,6 +63,7 @@ void gk20a_busy_noresume(struct gk20a *g) int gk20a_busy(struct gk20a *g) { + struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); int ret = 0; struct device *dev; @@ -71,7 +72,7 @@ int gk20a_busy(struct gk20a *g) atomic_inc(&g->usage_count.atomic_var); - down_read(&g->busy_lock); + down_read(&l->busy_lock); if (!gk20a_can_busy(g)) { ret = -ENODEV; @@ -107,7 +108,7 @@ int gk20a_busy(struct gk20a *g) } fail: - up_read(&g->busy_lock); + up_read(&l->busy_lock); return ret < 0 ? ret : 0; } @@ -282,12 +283,13 @@ static struct of_device_id tegra_gk20a_of_match[] = { * * In success, this call MUST be balanced by caller with __gk20a_do_unidle() * - * Acquires two locks : &g->busy_lock and &platform->railgate_lock + * Acquires two locks : &l->busy_lock and &platform->railgate_lock * In success, we hold these locks and return * In failure, we release these locks and return */ int __gk20a_do_idle(struct gk20a *g, bool force_reset) { + struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); struct device *dev = dev_from_gk20a(g); struct gk20a_platform *platform = dev_get_drvdata(dev); struct nvgpu_timeout timeout; @@ -303,7 +305,7 @@ int __gk20a_do_idle(struct gk20a *g, bool force_reset) gk20a_channel_deterministic_idle(g); /* acquire busy lock to block other busy() calls */ - down_write(&g->busy_lock); + down_write(&l->busy_lock); /* acquire railgate lock to prevent unrailgate in midst of do_idle() */ nvgpu_mutex_acquire(&platform->railgate_lock); @@ -406,7 +408,7 @@ fail_drop_usage_count: pm_runtime_put_noidle(dev); fail_timeout: nvgpu_mutex_release(&platform->railgate_lock); - up_write(&g->busy_lock); + up_write(&l->busy_lock); gk20a_channel_deterministic_unidle(g); return -EBUSY; } @@ -429,6 +431,7 @@ static int gk20a_do_idle(void *_g) */ int __gk20a_do_unidle(struct gk20a *g) { + struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); struct device *dev = dev_from_gk20a(g); struct gk20a_platform *platform = dev_get_drvdata(dev); int err; @@ -453,7 +456,7 @@ int __gk20a_do_unidle(struct gk20a *g) /* release the lock and open up all other busy() calls */ nvgpu_mutex_release(&platform->railgate_lock); - up_write(&g->busy_lock); + up_write(&l->busy_lock); gk20a_channel_deterministic_unidle(g); @@ -887,12 +890,12 @@ void gk20a_driver_start_unload(struct gk20a *g) gk20a_dbg(gpu_dbg_shutdown, "Driver is now going down!\n"); - down_write(&g->busy_lock); + down_write(&l->busy_lock); __nvgpu_set_enabled(g, NVGPU_DRIVER_IS_DYING, true); /* GR SW ready needs to be invalidated at this time with the busy lock * held to prevent a racing condition on the gr/mm code */ g->gr.sw_ready = false; - up_write(&g->busy_lock); + up_write(&l->busy_lock); if (g->is_virtual) return; diff --git a/drivers/gpu/nvgpu/common/linux/os_linux.h b/drivers/gpu/nvgpu/common/linux/os_linux.h index 160a5738..48479843 100644 --- a/drivers/gpu/nvgpu/common/linux/os_linux.h +++ b/drivers/gpu/nvgpu/common/linux/os_linux.h @@ -110,6 +110,8 @@ struct nvgpu_os_linux { struct dentry *debugfs_dump_ctxsw_stats; #endif struct gk20a_cde_app cde_app; + + struct rw_semaphore busy_lock; }; static inline struct nvgpu_os_linux *nvgpu_os_linux_from_gk20a(struct gk20a *g) diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index 537d03d8..51672b2f 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -1084,7 +1084,6 @@ struct gk20a { u32 log_mask; u32 log_trace; - struct rw_semaphore busy_lock; /* * Guards access to hardware when usual gk20a_{busy,idle} are skipped * for submits and held for channel lifetime but dropped for an ongoing diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.c b/drivers/gpu/nvgpu/vgpu/vgpu.c index b5765b86..5f672b11 100644 --- a/drivers/gpu/nvgpu/vgpu/vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/vgpu.c @@ -712,7 +712,7 @@ int vgpu_probe(struct platform_device *pdev) vgpu_init_vars(gk20a, platform); - init_rwsem(&gk20a->busy_lock); + init_rwsem(&l->busy_lock); nvgpu_spinlock_init(&gk20a->mc_enable_lock); -- cgit v1.2.2