Commit e45d7b7f authored by Du, Changbin's avatar Du, Changbin Committed by Zhenyu Wang

drm/i915/gvt: fix nested sleeping issue

We cannot use blocking method mutex_lock inside a wait loop.
Here we invoke pick_next_workload() which needs acquire a
mutex in our "condition" experssion. Then we go into a another
of the going-to-sleep sequence and changing the task state.
This is a dangerous. Let's rewrite the wait sequence to avoid
nested sleeping.

v2: fix do...while loop exit condition (zhenyu)
v3: rebase to gvt-staging branch
Signed-off-by: default avatarDu, Changbin <changbin.du@intel.com>
Signed-off-by: default avatarZhenyu Wang <zhenyuw@linux.intel.com>
parent 6fb5082a
...@@ -402,19 +402,24 @@ static int workload_thread(void *priv) ...@@ -402,19 +402,24 @@ static int workload_thread(void *priv)
struct intel_vgpu_workload *workload = NULL; struct intel_vgpu_workload *workload = NULL;
int ret; int ret;
bool need_force_wake = IS_SKYLAKE(gvt->dev_priv); bool need_force_wake = IS_SKYLAKE(gvt->dev_priv);
DEFINE_WAIT_FUNC(wait, woken_wake_function);
kfree(p); kfree(p);
gvt_dbg_core("workload thread for ring %d started\n", ring_id); gvt_dbg_core("workload thread for ring %d started\n", ring_id);
while (!kthread_should_stop()) { while (!kthread_should_stop()) {
ret = wait_event_interruptible(scheduler->waitq[ring_id], add_wait_queue(&scheduler->waitq[ring_id], &wait);
kthread_should_stop() || do {
(workload = pick_next_workload(gvt, ring_id))); workload = pick_next_workload(gvt, ring_id);
if (workload)
WARN_ON_ONCE(ret); break;
wait_woken(&wait, TASK_INTERRUPTIBLE,
if (kthread_should_stop()) MAX_SCHEDULE_TIMEOUT);
} while (!kthread_should_stop());
remove_wait_queue(&scheduler->waitq[ring_id], &wait);
if (!workload)
break; break;
mutex_lock(&scheduler_mutex); mutex_lock(&scheduler_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment