Commit 66bbc3b2 authored by Chris Wilson's avatar Chris Wilson Committed by Zhenyu Wang

drm/i915/gvt: Stop waiting whilst holding struct_mutex

For whatever reason, the gvt scheduler runs synchronously. At the very
least, lets run synchronously without holding the struct_mutex.

v2: cut'n'paste mutex_lock instead of unlock.
Replace long hold of struct_mutex with a mutex to serialise the worker
threads.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarZhenyu Wang <zhenyuw@linux.intel.com>
parent f460c251
...@@ -390,6 +390,8 @@ struct workload_thread_param { ...@@ -390,6 +390,8 @@ struct workload_thread_param {
int ring_id; int ring_id;
}; };
static DEFINE_MUTEX(scheduler_mutex);
static int workload_thread(void *priv) static int workload_thread(void *priv)
{ {
struct workload_thread_param *p = (struct workload_thread_param *)priv; struct workload_thread_param *p = (struct workload_thread_param *)priv;
...@@ -414,17 +416,14 @@ static int workload_thread(void *priv) ...@@ -414,17 +416,14 @@ static int workload_thread(void *priv)
if (kthread_should_stop()) if (kthread_should_stop())
break; break;
mutex_lock(&scheduler_mutex);
gvt_dbg_sched("ring id %d next workload %p vgpu %d\n", gvt_dbg_sched("ring id %d next workload %p vgpu %d\n",
workload->ring_id, workload, workload->ring_id, workload,
workload->vgpu->id); workload->vgpu->id);
intel_runtime_pm_get(gvt->dev_priv); intel_runtime_pm_get(gvt->dev_priv);
/*
* Always take i915 big lock first
*/
mutex_lock(&gvt->dev_priv->drm.struct_mutex);
gvt_dbg_sched("ring id %d will dispatch workload %p\n", gvt_dbg_sched("ring id %d will dispatch workload %p\n",
workload->ring_id, workload); workload->ring_id, workload);
...@@ -432,7 +431,10 @@ static int workload_thread(void *priv) ...@@ -432,7 +431,10 @@ static int workload_thread(void *priv)
intel_uncore_forcewake_get(gvt->dev_priv, intel_uncore_forcewake_get(gvt->dev_priv,
FORCEWAKE_ALL); FORCEWAKE_ALL);
mutex_lock(&gvt->dev_priv->drm.struct_mutex);
ret = dispatch_workload(workload); ret = dispatch_workload(workload);
mutex_unlock(&gvt->dev_priv->drm.struct_mutex);
if (ret) { if (ret) {
gvt_err("fail to dispatch workload, skip\n"); gvt_err("fail to dispatch workload, skip\n");
goto complete; goto complete;
...@@ -442,8 +444,7 @@ static int workload_thread(void *priv) ...@@ -442,8 +444,7 @@ static int workload_thread(void *priv)
workload->ring_id, workload); workload->ring_id, workload);
workload->status = i915_wait_request(workload->req, workload->status = i915_wait_request(workload->req,
I915_WAIT_LOCKED, 0, NULL, NULL);
NULL, NULL);
if (workload->status != 0) if (workload->status != 0)
gvt_err("fail to wait workload, skip\n"); gvt_err("fail to wait workload, skip\n");
...@@ -451,7 +452,9 @@ static int workload_thread(void *priv) ...@@ -451,7 +452,9 @@ static int workload_thread(void *priv)
gvt_dbg_sched("will complete workload %p\n, status: %d\n", gvt_dbg_sched("will complete workload %p\n, status: %d\n",
workload, workload->status); workload, workload->status);
mutex_lock(&gvt->dev_priv->drm.struct_mutex);
complete_current_workload(gvt, ring_id); complete_current_workload(gvt, ring_id);
mutex_unlock(&gvt->dev_priv->drm.struct_mutex);
i915_gem_request_put(fetch_and_zero(&workload->req)); i915_gem_request_put(fetch_and_zero(&workload->req));
...@@ -459,9 +462,10 @@ static int workload_thread(void *priv) ...@@ -459,9 +462,10 @@ static int workload_thread(void *priv)
intel_uncore_forcewake_put(gvt->dev_priv, intel_uncore_forcewake_put(gvt->dev_priv,
FORCEWAKE_ALL); FORCEWAKE_ALL);
mutex_unlock(&gvt->dev_priv->drm.struct_mutex);
intel_runtime_pm_put(gvt->dev_priv); intel_runtime_pm_put(gvt->dev_priv);
mutex_unlock(&scheduler_mutex);
} }
return 0; return 0;
} }
......
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