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/common/mm/nvgpu_allocator.c | 4 ++-- drivers/gpu/nvgpu/common/nvgpu_common.c | 14 +++++++------- drivers/gpu/nvgpu/common/semaphore.c | 18 +++++++++--------- 3 files changed, 18 insertions(+), 18 deletions(-) (limited to 'drivers/gpu/nvgpu/common') diff --git a/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c b/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c index cf8c4569..20209efc 100644 --- a/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c @@ -1,7 +1,7 @@ /* * gk20a allocator * - * Copyright (c) 2011-2016, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2011-2017, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -140,7 +140,7 @@ int __nvgpu_alloc_common_init(struct nvgpu_allocator *a, a->priv = priv; a->debug = dbg; - mutex_init(&a->lock); + nvgpu_mutex_init(&a->lock); strlcpy(a->name, name, sizeof(a->name)); diff --git a/drivers/gpu/nvgpu/common/nvgpu_common.c b/drivers/gpu/nvgpu/common/nvgpu_common.c index 80f1cca0..6b5cfa55 100644 --- a/drivers/gpu/nvgpu/common/nvgpu_common.c +++ b/drivers/gpu/nvgpu/common/nvgpu_common.c @@ -34,13 +34,13 @@ static void nvgpu_init_vars(struct gk20a *g) init_rwsem(&g->busy_lock); - spin_lock_init(&g->mc_enable_lock); + nvgpu_spinlock_init(&g->mc_enable_lock); - mutex_init(&platform->railgate_lock); - mutex_init(&g->dbg_sessions_lock); - mutex_init(&g->client_lock); - mutex_init(&g->ch_wdt_lock); - mutex_init(&g->poweroff_lock); + nvgpu_mutex_init(&platform->railgate_lock); + nvgpu_mutex_init(&g->dbg_sessions_lock); + nvgpu_mutex_init(&g->client_lock); + nvgpu_mutex_init(&g->ch_wdt_lock); + nvgpu_mutex_init(&g->poweroff_lock); g->regs_saved = g->regs; g->bar1_saved = g->bar1; @@ -52,7 +52,7 @@ static void nvgpu_init_vars(struct gk20a *g) dma_set_max_seg_size(g->dev, UINT_MAX); INIT_LIST_HEAD(&g->pending_sema_waits); - raw_spin_lock_init(&g->pending_sema_waits_lock); + nvgpu_raw_spinlock_init(&g->pending_sema_waits_lock); } static void nvgpu_init_timeout(struct gk20a *g) diff --git a/drivers/gpu/nvgpu/common/semaphore.c b/drivers/gpu/nvgpu/common/semaphore.c index 4bf8695d..919f26ec 100644 --- a/drivers/gpu/nvgpu/common/semaphore.c +++ b/drivers/gpu/nvgpu/common/semaphore.c @@ -24,13 +24,13 @@ #define __lock_sema_sea(s) \ do { \ gpu_sema_verbose_dbg("Acquiring sema lock..."); \ - mutex_lock(&s->sea_lock); \ + nvgpu_mutex_acquire(&s->sea_lock); \ gpu_sema_verbose_dbg("Sema lock aquried!"); \ } while (0) #define __unlock_sema_sea(s) \ do { \ - mutex_unlock(&s->sea_lock); \ + nvgpu_mutex_release(&s->sea_lock); \ gpu_sema_verbose_dbg("Released sema lock"); \ } while (0) @@ -81,7 +81,7 @@ struct nvgpu_semaphore_sea *nvgpu_semaphore_sea_create(struct gk20a *g) g->sema_sea->page_count = 0; g->sema_sea->gk20a = g; INIT_LIST_HEAD(&g->sema_sea->pool_list); - mutex_init(&g->sema_sea->sea_lock); + nvgpu_mutex_init(&g->sema_sea->sea_lock); if (__nvgpu_semaphore_sea_grow(g->sema_sea)) goto cleanup; @@ -138,7 +138,7 @@ struct nvgpu_semaphore_pool *nvgpu_semaphore_pool_alloc( p->sema_sea = sea; INIT_LIST_HEAD(&p->hw_semas); kref_init(&p->ref); - mutex_init(&p->pool_lock); + nvgpu_mutex_init(&p->pool_lock); sea->page_count++; list_add(&p->pool_list_entry, &sea->pool_list); @@ -344,7 +344,7 @@ static int __nvgpu_init_hw_sema(struct channel_gk20a *ch) BUG_ON(!p); - mutex_lock(&p->pool_lock); + nvgpu_mutex_acquire(&p->pool_lock); /* Find an available HW semaphore. */ hw_sema_idx = __semaphore_bitmap_alloc(p->semas_alloced, @@ -371,14 +371,14 @@ static int __nvgpu_init_hw_sema(struct channel_gk20a *ch) list_add(&hw_sema->hw_sema_list, &p->hw_semas); - mutex_unlock(&p->pool_lock); + nvgpu_mutex_release(&p->pool_lock); return 0; fail_free_idx: clear_bit(hw_sema_idx, p->semas_alloced); fail: - mutex_unlock(&p->pool_lock); + nvgpu_mutex_release(&p->pool_lock); return ret; } @@ -391,7 +391,7 @@ void nvgpu_semaphore_free_hw_sema(struct channel_gk20a *ch) BUG_ON(!p); - mutex_lock(&p->pool_lock); + nvgpu_mutex_acquire(&p->pool_lock); clear_bit(ch->hw_sema->idx, p->semas_alloced); @@ -400,7 +400,7 @@ void nvgpu_semaphore_free_hw_sema(struct channel_gk20a *ch) kfree(ch->hw_sema); ch->hw_sema = NULL; - mutex_unlock(&p->pool_lock); + nvgpu_mutex_release(&p->pool_lock); } /* -- cgit v1.2.2