From 505b442551a2e27aa3bc9e608c5a2bc9fccecbc4 Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Mon, 19 Dec 2016 16:31:43 +0530 Subject: gpu: nvgpu: acquire mutex for notifier read We use &ch->error_notifier_mutex to protect writes and free of error notifier But we currently do not protect reading of notifier in gk20a_fifo_set_ctx_mmu_error() and vgpu_fifo_set_ctx_mmu_error() Add new API gk20a_set_error_notifier_locked() which is same as gk20a_set_error_notifier() but without the locks. In *_fifo_set_ctx_mmu_error() APIs, acquire the mutex explicitly, and then use this new API gk20a_set_error_notifier() will now just call gk20a_set_error_notifier_locked() within a mutex Bug 1824788 Bug 1844312 Change-Id: I1f3831dc63fe1daa761b2e17e4de3c155f505d6f Signed-off-by: Deepak Nibade Reviewed-on: http://git-master/r/1273471 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Richard Zhao GVS: Gerrit_Virtual_Submit Reviewed-by: Bharat Nihalani --- drivers/gpu/nvgpu/vgpu/fifo_vgpu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'drivers/gpu/nvgpu/vgpu/fifo_vgpu.c') diff --git a/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c b/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c index 5ffc6a00..e9a2d582 100644 --- a/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c @@ -678,17 +678,20 @@ 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) { - if (ch->error_notifier) { + mutex_lock(&ch->error_notifier_mutex); + if (ch->error_notifier_ref) { if (ch->error_notifier->status == 0xffff) { /* If error code is already set, this mmu fault * was triggered as part of recovery from other * error condition. * Don't overwrite error flag. */ } else { - gk20a_set_error_notifier(ch, + gk20a_set_error_notifier_locked(ch, NVGPU_CHANNEL_FIFO_ERROR_MMU_ERR_FLT); } } + mutex_unlock(&ch->error_notifier_mutex); + /* mark channel as faulted */ ch->has_timedout = true; wmb(); -- cgit v1.2.2