gpu: nvgpu: hold mutex to get cde context only

In gk20a_cde_convert(), we hold cde_app.mutex almost
for everything which is unnecessary

Also, this causes a deadlock scenario when gk20a_do_idle()
is called
In some cases it is possible that Thread 1
holds the lock and is trying to power on GPU, and
Thread 2 is trying to power off GPU and then grab
cde_app.mutex to cleanup GPU state

To fix this, grab the mutex only for gk20a_cde_get_context()
and then release it

Bug 200287073

Change-Id: Ic4856604652d0d4024abdeb5c2f8f03910c601a5
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/1324328
(cherry picked from commit 3c8eef0d0e)
Reviewed-on: http://git-master/r/1322030
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
This commit is contained in:
Deepak Nibade
2017-03-16 15:52:55 +05:30
committed by mobile promotions
parent ebe71ea9a2
commit 978d13efe5

View File

@@ -950,8 +950,8 @@ __releases(&cde_app->mutex)
return -EINVAL;
nvgpu_mutex_acquire(&g->cde_app.mutex);
cde_ctx = gk20a_cde_get_context(g);
nvgpu_mutex_release(&g->cde_app.mutex);
if (IS_ERR(cde_ctx)) {
err = PTR_ERR(cde_ctx);
goto exit_unlock;
@@ -1121,7 +1121,6 @@ exit_unlock:
if (surface)
dma_buf_vunmap(compbits_scatter_buf, surface);
nvgpu_mutex_release(&g->cde_app.mutex);
return err;
}