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/vgpu/fifo_vgpu.c | 18 +++++++++--------- drivers/gpu/nvgpu/vgpu/gr_vgpu.c | 12 ++++++------ drivers/gpu/nvgpu/vgpu/mm_vgpu.c | 6 +++--- drivers/gpu/nvgpu/vgpu/vgpu.c | 8 ++++---- 4 files changed, 22 insertions(+), 22 deletions(-) (limited to 'drivers/gpu/nvgpu/vgpu') diff --git a/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c b/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c index 339f2237..7b6ed322 100644 --- a/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c @@ -1,7 +1,7 @@ /* * Virtualized GPU Fifo * - * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2014-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, @@ -218,7 +218,7 @@ static int init_runlist(struct gk20a *g, struct fifo_gk20a *f) goto clean_up_runlist; } } - mutex_init(&runlist->mutex); + nvgpu_mutex_init(&runlist->mutex); /* None of buffers is pinned if this value doesn't change. Otherwise, one of them (cur_buffer) must have been pinned. */ @@ -294,7 +294,7 @@ static int vgpu_init_fifo_setup_sw(struct gk20a *g) init_runlist(g, f); INIT_LIST_HEAD(&f->free_chs); - mutex_init(&f->free_chs_mutex); + nvgpu_mutex_init(&f->free_chs_mutex); for (chid = 0; chid < f->num_channels; chid++) { f->channel[chid].userd_iova = @@ -306,10 +306,10 @@ static int vgpu_init_fifo_setup_sw(struct gk20a *g) gk20a_init_channel_support(g, chid); gk20a_init_tsg_support(g, chid); } - mutex_init(&f->tsg_inuse_mutex); + nvgpu_mutex_init(&f->tsg_inuse_mutex); f->deferred_reset_pending = false; - mutex_init(&f->deferred_reset_mutex); + nvgpu_mutex_init(&f->deferred_reset_mutex); f->sw_ready = true; @@ -534,12 +534,12 @@ static int vgpu_fifo_update_runlist(struct gk20a *g, u32 runlist_id, runlist = &f->runlist_info[runlist_id]; - mutex_lock(&runlist->mutex); + nvgpu_mutex_acquire(&runlist->mutex); ret = vgpu_fifo_update_runlist_locked(g, runlist_id, hw_chid, add, wait_for_finish); - mutex_unlock(&runlist->mutex); + nvgpu_mutex_release(&runlist->mutex); return ret; } @@ -679,7 +679,7 @@ static int vgpu_fifo_force_reset_ch(struct channel_gk20a *ch, static void vgpu_fifo_set_ctx_mmu_error(struct gk20a *g, struct channel_gk20a *ch) { - mutex_lock(&ch->error_notifier_mutex); + nvgpu_mutex_acquire(&ch->error_notifier_mutex); if (ch->error_notifier_ref) { if (ch->error_notifier->status == 0xffff) { /* If error code is already set, this mmu fault @@ -691,7 +691,7 @@ static void vgpu_fifo_set_ctx_mmu_error(struct gk20a *g, NVGPU_CHANNEL_FIFO_ERROR_MMU_ERR_FLT); } } - mutex_unlock(&ch->error_notifier_mutex); + nvgpu_mutex_release(&ch->error_notifier_mutex); /* mark channel as faulted */ ch->has_timedout = true; diff --git a/drivers/gpu/nvgpu/vgpu/gr_vgpu.c b/drivers/gpu/nvgpu/vgpu/gr_vgpu.c index 36bbee00..5c637d25 100644 --- a/drivers/gpu/nvgpu/vgpu/gr_vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/gr_vgpu.c @@ -866,7 +866,7 @@ static int vgpu_gr_init_gr_setup_sw(struct gk20a *g) gr->g = g; #if defined(CONFIG_GK20A_CYCLE_STATS) - mutex_init(&g->gr.cs_lock); + nvgpu_mutex_init(&g->gr.cs_lock); #endif err = vgpu_gr_init_gr_config(g, gr); @@ -885,7 +885,7 @@ static int vgpu_gr_init_gr_setup_sw(struct gk20a *g) if (err) goto clean_up; - mutex_init(&gr->ctx_mutex); + nvgpu_mutex_init(&gr->ctx_mutex); gr->sm_error_states = kzalloc( sizeof(struct nvgpu_dbg_gpu_sm_error_state_record) * @@ -1078,9 +1078,9 @@ static int vgpu_gr_clear_sm_error_state(struct gk20a *g, { struct gr_gk20a *gr = &g->gr; - mutex_lock(&g->dbg_sessions_lock); + nvgpu_mutex_acquire(&g->dbg_sessions_lock); memset(&gr->sm_error_states[sm_id], 0, sizeof(*gr->sm_error_states)); - mutex_unlock(&g->dbg_sessions_lock); + nvgpu_mutex_release(&g->dbg_sessions_lock); return 0; } @@ -1096,7 +1096,7 @@ void vgpu_gr_handle_sm_esr_event(struct gk20a *g, return; } - mutex_lock(&g->dbg_sessions_lock); + nvgpu_mutex_acquire(&g->dbg_sessions_lock); sm_error_states = &g->gr.sm_error_states[info->sm_id]; @@ -1108,7 +1108,7 @@ void vgpu_gr_handle_sm_esr_event(struct gk20a *g, sm_error_states->hww_warp_esr_report_mask = info->hww_warp_esr_report_mask; - mutex_unlock(&g->dbg_sessions_lock); + nvgpu_mutex_release(&g->dbg_sessions_lock); } void vgpu_init_gr_ops(struct gpu_ops *gops) diff --git a/drivers/gpu/nvgpu/vgpu/mm_vgpu.c b/drivers/gpu/nvgpu/vgpu/mm_vgpu.c index c6780cf7..70b50e7e 100644 --- a/drivers/gpu/nvgpu/vgpu/mm_vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/mm_vgpu.c @@ -200,7 +200,7 @@ static void vgpu_vm_remove_support(struct vm_gk20a *vm) int err; gk20a_dbg_fn(""); - mutex_lock(&vm->update_gmmu_lock); + nvgpu_mutex_acquire(&vm->update_gmmu_lock); /* TBD: add a flag here for the unmap code to recognize teardown * and short-circuit any otherwise expensive operations. */ @@ -231,7 +231,7 @@ static void vgpu_vm_remove_support(struct vm_gk20a *vm) if (nvgpu_alloc_initialized(&vm->user)) nvgpu_alloc_destroy(&vm->user); - mutex_unlock(&vm->update_gmmu_lock); + nvgpu_mutex_release(&vm->update_gmmu_lock); /* vm is not used anymore. release it. */ kfree(vm); @@ -401,7 +401,7 @@ static int vgpu_vm_alloc_share(struct gk20a_as_share *as_share, vm->mapped_buffers = RB_ROOT; - mutex_init(&vm->update_gmmu_lock); + nvgpu_mutex_init(&vm->update_gmmu_lock); kref_init(&vm->ref); INIT_LIST_HEAD(&vm->reserved_va_list); diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.c b/drivers/gpu/nvgpu/vgpu/vgpu.c index ba387de9..4c88ab96 100644 --- a/drivers/gpu/nvgpu/vgpu/vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/vgpu.c @@ -250,9 +250,9 @@ static int vgpu_init_support(struct platform_device *pdev) } g->bar1_mem = r; - mutex_init(&g->dbg_sessions_lock); - mutex_init(&g->client_lock); - mutex_init(&g->ch_wdt_lock); + nvgpu_mutex_init(&g->dbg_sessions_lock); + nvgpu_mutex_init(&g->client_lock); + nvgpu_mutex_init(&g->ch_wdt_lock); g->dbg_regops_tmp_buf = kzalloc(SZ_4K, GFP_KERNEL); if (!g->dbg_regops_tmp_buf) { @@ -576,7 +576,7 @@ int vgpu_probe(struct platform_device *pdev) init_rwsem(&gk20a->busy_lock); - spin_lock_init(&gk20a->mc_enable_lock); + nvgpu_spinlock_init(&gk20a->mc_enable_lock); /* Initialize the platform interface. */ err = platform->probe(dev); -- cgit v1.2.2