From 76611c4268dec892b170fb245badfca5319fd645 Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Wed, 1 Feb 2017 15:06:27 +0530 Subject: gpu: nvgpu: remove use of mutex_is_locked() mutex_is_locked() API is defined on Linux only and not on other OS like QNX. Hence remove use of this API for OS abstraction support to nvgpu. Instead of using mutex_is_locked(), use mutex_trylock() for same purpose Jira NVGPU-13 Change-Id: I542daf20a2294153da8e8bfe89e0dc0387297523 Signed-off-by: Deepak Nibade Reviewed-on: http://git-master/r/1297184 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 8 +++----- drivers/gpu/nvgpu/gk20a/fifo_gk20a.c | 8 +++----- drivers/gpu/nvgpu/gk20a/sched_gk20a.c | 8 +++++++- 3 files changed, 13 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index 3dda1cbf..376a64b0 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c @@ -906,7 +906,6 @@ static void gk20a_free_channel(struct channel_gk20a *ch, bool force) struct dbg_session_gk20a *dbg_s; struct dbg_session_data *session_data, *tmp_s; struct dbg_session_channel_data *ch_data, *tmp; - bool was_reset; gk20a_dbg_fn(""); @@ -953,13 +952,12 @@ static void gk20a_free_channel(struct channel_gk20a *ch, bool force) if (g->fifo.deferred_reset_pending) { gk20a_dbg(gpu_dbg_intr | gpu_dbg_gpu_dbg, "engine reset was" " deferred, running now"); - was_reset = mutex_is_locked(&g->fifo.gr_reset_mutex); - mutex_lock(&g->fifo.gr_reset_mutex); /* if lock is already taken, a reset is taking place so no need to repeat */ - if (!was_reset) + if (mutex_trylock(&g->fifo.gr_reset_mutex)) { gk20a_fifo_deferred_reset(g, ch); - mutex_unlock(&g->fifo.gr_reset_mutex); + mutex_unlock(&g->fifo.gr_reset_mutex); + } } mutex_unlock(&f->deferred_reset_mutex); diff --git a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c index c6b444f9..4a32194c 100644 --- a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c @@ -1401,7 +1401,6 @@ static bool gk20a_fifo_handle_mmu_fault( struct channel_gk20a *ch = NULL; struct tsg_gk20a *tsg = NULL; struct channel_gk20a *referenced_channel = NULL; - bool was_reset; /* read and parse engine status */ u32 status = gk20a_readl(g, fifo_engine_status_r(engine_id)); u32 ctx_status = fifo_engine_status_ctx_status_v(status); @@ -1486,13 +1485,12 @@ static bool gk20a_fifo_handle_mmu_fault( "sm debugger attached," " deferring channel recovery to channel free"); } else if (engine_id != FIFO_INVAL_ENGINE_ID) { - was_reset = mutex_is_locked(&g->fifo.gr_reset_mutex); - mutex_lock(&g->fifo.gr_reset_mutex); /* if lock is already taken, a reset is taking place so no need to repeat */ - if (!was_reset) + if (mutex_trylock(&g->fifo.gr_reset_mutex)) { gk20a_fifo_reset_engine(g, engine_id); - mutex_unlock(&g->fifo.gr_reset_mutex); + mutex_unlock(&g->fifo.gr_reset_mutex); + } } if (ch) diff --git a/drivers/gpu/nvgpu/gk20a/sched_gk20a.c b/drivers/gpu/nvgpu/gk20a/sched_gk20a.c index 54dbcfd1..20cd1232 100644 --- a/drivers/gpu/nvgpu/gk20a/sched_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/sched_gk20a.c @@ -520,6 +520,7 @@ static int gk20a_sched_debugfs_show(struct seq_file *s, void *unused) struct device *dev = s->private; struct gk20a *g = gk20a_get_platform(dev)->g; struct gk20a_sched_ctrl *sched = &g->sched_ctrl; + bool sched_busy = true; int n = sched->bitmap_size / sizeof(u64); int i; @@ -529,8 +530,13 @@ static int gk20a_sched_debugfs_show(struct seq_file *s, void *unused) if (err) return err; + if (mutex_trylock(&sched->busy_lock)) { + sched_busy = false; + mutex_unlock(&sched->busy_lock); + } + seq_printf(s, "control_locked=%d\n", sched->control_locked); - seq_printf(s, "busy=%d\n", mutex_is_locked(&sched->busy_lock)); + seq_printf(s, "busy=%d\n", sched_busy); seq_printf(s, "bitmap_size=%zu\n", sched->bitmap_size); mutex_lock(&sched->status_lock); -- cgit v1.2.2