From 8ee3aa4b3175d8d27e57a0f5d5e2cdf3d78a4a58 Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Tue, 24 Jan 2017 19:00:42 +0530 Subject: gpu: nvgpu: use common nvgpu mutex/spinlock APIs Instead of using Linux APIs for mutex and spinlocks directly, use new APIs defined in Replace Linux specific mutex/spinlock declaration, init, lock, unlock APIs with new APIs e.g struct mutex is replaced by struct nvgpu_mutex and mutex_lock() is replaced by nvgpu_mutex_acquire() And also include instead of including and Add explicit nvgpu/lock.h includes to below files to fix complilation failures. gk20a/platform_gk20a.h include/nvgpu/allocator.h Jira NVGPU-13 Change-Id: I81a05d21ecdbd90c2076a9f0aefd0e40b215bd33 Signed-off-by: Deepak Nibade Reviewed-on: http://git-master/r/1293187 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/gk20a.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a/gk20a.c') diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c index 79c3fd09..32570d3d 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include @@ -795,13 +795,13 @@ static int gk20a_pm_prepare_poweroff(struct device *dev) gk20a_dbg_fn(""); - mutex_lock(&g->poweroff_lock); + nvgpu_mutex_acquire(&g->poweroff_lock); if (!g->power_on) goto done; if (gk20a_fifo_is_engine_busy(g)) { - mutex_unlock(&g->poweroff_lock); + nvgpu_mutex_release(&g->poweroff_lock); return -EBUSY; } gk20a_scale_suspend(dev); @@ -844,7 +844,7 @@ static int gk20a_pm_prepare_poweroff(struct device *dev) gk20a_lockout_registers(g); done: - mutex_unlock(&g->poweroff_lock); + nvgpu_mutex_release(&g->poweroff_lock); return ret; } @@ -1373,9 +1373,9 @@ static int gk20a_pm_unrailgate(struct device *dev) trace_gk20a_pm_unrailgate(dev_name(dev)); if (platform->unrailgate) { - mutex_lock(&platform->railgate_lock); + nvgpu_mutex_acquire(&platform->railgate_lock); ret = platform->unrailgate(dev); - mutex_unlock(&platform->railgate_lock); + nvgpu_mutex_release(&platform->railgate_lock); } #ifdef CONFIG_DEBUG_FS @@ -1896,11 +1896,11 @@ void gk20a_disable(struct gk20a *g, u32 units) gk20a_dbg(gpu_dbg_info, "pmc disable: %08x\n", units); - spin_lock(&g->mc_enable_lock); + nvgpu_spinlock_acquire(&g->mc_enable_lock); pmc = gk20a_readl(g, mc_enable_r()); pmc &= ~units; gk20a_writel(g, mc_enable_r(), pmc); - spin_unlock(&g->mc_enable_lock); + nvgpu_spinlock_release(&g->mc_enable_lock); } void gk20a_enable(struct gk20a *g, u32 units) @@ -1909,12 +1909,12 @@ void gk20a_enable(struct gk20a *g, u32 units) gk20a_dbg(gpu_dbg_info, "pmc enable: %08x\n", units); - spin_lock(&g->mc_enable_lock); + nvgpu_spinlock_acquire(&g->mc_enable_lock); pmc = gk20a_readl(g, mc_enable_r()); pmc |= units; gk20a_writel(g, mc_enable_r(), pmc); gk20a_readl(g, mc_enable_r()); - spin_unlock(&g->mc_enable_lock); + nvgpu_spinlock_release(&g->mc_enable_lock); udelay(20); } @@ -1953,7 +1953,7 @@ int __gk20a_do_idle(struct device *dev, bool force_reset) down_write(&g->busy_lock); /* acquire railgate lock to prevent unrailgate in midst of do_idle() */ - mutex_lock(&platform->railgate_lock); + nvgpu_mutex_acquire(&platform->railgate_lock); /* check if it is already railgated ? */ if (platform->is_railgated(dev)) @@ -1963,7 +1963,7 @@ int __gk20a_do_idle(struct device *dev, bool force_reset) * release railgate_lock, prevent suspend by incrementing usage counter, * re-acquire railgate_lock */ - mutex_unlock(&platform->railgate_lock); + nvgpu_mutex_release(&platform->railgate_lock); pm_runtime_get_sync(dev); /* @@ -1975,7 +1975,7 @@ int __gk20a_do_idle(struct device *dev, bool force_reset) target_ref_cnt = 2; else target_ref_cnt = 1; - mutex_lock(&platform->railgate_lock); + nvgpu_mutex_acquire(&platform->railgate_lock); nvgpu_timeout_init(g, &timeout, GK20A_WAIT_FOR_IDLE_MS, NVGPU_TIMER_CPU_TIMER); @@ -2052,7 +2052,7 @@ int __gk20a_do_idle(struct device *dev, bool force_reset) fail_drop_usage_count: pm_runtime_put_noidle(dev); fail_timeout: - mutex_unlock(&platform->railgate_lock); + nvgpu_mutex_release(&platform->railgate_lock); up_write(&g->busy_lock); return -EBUSY; } @@ -2101,7 +2101,7 @@ int __gk20a_do_unidle(struct device *dev) } /* release the lock and open up all other busy() calls */ - mutex_unlock(&platform->railgate_lock); + nvgpu_mutex_release(&platform->railgate_lock); up_write(&g->busy_lock); return 0; -- cgit v1.2.2