gpu: nvgpu: fix deadlock on timeout lock

In gk20a_channel_timeout_stop(), we take the channel's
timeout lock and then cancel the timeout worker thread

Timeout worker thread also tries to acquire same timeout
lock.

Hence, while cancelling the timeout in gk20a_channel_timeout_stop()
if the timeout_handler is already scheduled, we will have a deadlock

Fix this by moving cancel_delayed_work_sync() out of the locks

Bug 200133289
Bug 1695481

Change-Id: Iea78770180b483a63e5e176efba27831174e9dde
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/815922
Reviewed-by: Ishan Mittal <imittal@nvidia.com>
Tested-by: Ishan Mittal <imittal@nvidia.com>
This commit is contained in:
Deepak Nibade
2015-10-12 14:21:34 +05:30
committed by Ishan Mittal
parent 68099f8298
commit da8ff40e55

View File

@@ -1561,15 +1561,16 @@ static void gk20a_channel_timeout_start(struct channel_gk20a *ch,
static void gk20a_channel_timeout_stop(struct channel_gk20a *ch)
{
mutex_lock(&ch->timeout.lock);
if (!ch->timeout.initialized) {
mutex_unlock(&ch->timeout.lock);
return;
}
mutex_unlock(&ch->timeout.lock);
ch->timeout.initialized = false;
cancel_delayed_work_sync(&ch->timeout.wq);
mutex_lock(&ch->timeout.lock);
ch->timeout.initialized = false;
mutex_unlock(&ch->timeout.lock);
}