From d8d0a5138dc66c8cbfa1d2355392fec1719f798f Mon Sep 17 00:00:00 2001 From: Harshitha Sai Neelati Date: Fri, 25 Sep 2020 15:14:37 +0530 Subject: [PATCH] msm: kgsl: Don't wait for room in context queue when context is invalidated In a condition where there is no room in the drawcontext queue and the context is invalidated while sleeping in wait_event_interruptible_timeout, we are now polling for room after wake up. This would lead to infinite looping. Hence, do not wait for room in context queue if context is invalidated. Change-Id: I12c80e71630da2f3316838bee37f13cfa3b8e7d9 Signed-off-by: Harshitha Sai Neelati --- drivers/gpu/msm/adreno_dispatch.c | 21 +++++++++++---------- drivers/gpu/msm/adreno_hwsched.c | 21 +++++++++++---------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/msm/adreno_dispatch.c b/drivers/gpu/msm/adreno_dispatch.c index 88d4e734f377..31f7a2646755 100644 --- a/drivers/gpu/msm/adreno_dispatch.c +++ b/drivers/gpu/msm/adreno_dispatch.c @@ -1181,7 +1181,16 @@ static inline int _wait_for_room_in_context_queue( spin_lock(&drawctxt->lock); trace_adreno_drawctxt_wake(drawctxt); - if (ret <= 0) + /* + * Account for the possibility that the context got invalidated + * while we were sleeping + */ + + if (ret > 0) { + ret = _check_context_state(&drawctxt->base); + if (ret) + return ret; + } else return (ret == 0) ? -ETIMEDOUT : (int) ret; } @@ -1196,15 +1205,7 @@ static unsigned int _check_context_state_to_queue_cmds( if (ret) return ret; - ret = _wait_for_room_in_context_queue(drawctxt); - if (ret) - return ret; - - /* - * Account for the possiblity that the context got invalidated - * while we were sleeping - */ - return _check_context_state(&drawctxt->base); + return _wait_for_room_in_context_queue(drawctxt); } static void _queue_drawobj(struct adreno_context *drawctxt, diff --git a/drivers/gpu/msm/adreno_hwsched.c b/drivers/gpu/msm/adreno_hwsched.c index 7accee6ef2bc..3cf94e2a5412 100644 --- a/drivers/gpu/msm/adreno_hwsched.c +++ b/drivers/gpu/msm/adreno_hwsched.c @@ -704,7 +704,16 @@ static inline int _wait_for_room_in_context_queue( spin_lock(&drawctxt->lock); trace_adreno_drawctxt_wake(drawctxt); - if (ret <= 0) + /* + * Account for the possibility that the context got invalidated + * while we were sleeping + */ + + if (ret > 0) { + ret = _check_context_state(&drawctxt->base); + if (ret) + return ret; + } else return (ret == 0) ? -ETIMEDOUT : (int) ret; } @@ -719,15 +728,7 @@ static unsigned int _check_context_state_to_queue_cmds( if (ret) return ret; - ret = _wait_for_room_in_context_queue(drawctxt); - if (ret) - return ret; - - /* - * Account for the possiblity that the context got invalidated - * while we were sleeping - */ - return _check_context_state(&drawctxt->base); + return _wait_for_room_in_context_queue(drawctxt); } static void _queue_drawobj(struct adreno_context *drawctxt,