From da8ff40e55c498f2ca24d446d45cda9d4d83bbcf Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Mon, 12 Oct 2015 14:21:34 +0530 Subject: 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 Reviewed-on: http://git-master/r/815922 Reviewed-by: Ishan Mittal Tested-by: Ishan Mittal --- drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a/channel_gk20a.c') diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index 6dad412a..6f0d7375 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c @@ -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); } -- cgit v1.2.2