diff options
author | Zhenyu Wang <zhenyuw@linux.intel.com> | 2016-11-24 02:55:49 -0500 |
---|---|---|
committer | Zhenyu Wang <zhenyuw@linux.intel.com> | 2016-11-24 20:18:11 -0500 |
commit | 53d6f812c0dbf1c9cad89b1c2118e61c13ca9677 (patch) | |
tree | 1135ed9f9c1415a259320d45999e7cd426f73844 | |
parent | 550dd77ebb6360120269d9a7102ae2c0cea41290 (diff) |
drm/i915/gvt: fix lock not released bug for dispatch_workload() err path
Need to be careful to release struct_mutext when request alloc
failed and take consistent handling for return status as with
normal go out path. Ensure to check correct workload request in
complete path too.
v2: Add Fixes note
Fixes: 90d27a1b180e ("drm/i915/gvt: fix deadlock in workload_thread")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Pei Zhang <pei.zhang@intel.com>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
-rw-r--r-- | drivers/gpu/drm/i915/gvt/scheduler.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c index f898df38dd9a..4db242250235 100644 --- a/drivers/gpu/drm/i915/gvt/scheduler.c +++ b/drivers/gpu/drm/i915/gvt/scheduler.c | |||
@@ -177,8 +177,8 @@ static int dispatch_workload(struct intel_vgpu_workload *workload) | |||
177 | rq = i915_gem_request_alloc(dev_priv->engine[ring_id], shadow_ctx); | 177 | rq = i915_gem_request_alloc(dev_priv->engine[ring_id], shadow_ctx); |
178 | if (IS_ERR(rq)) { | 178 | if (IS_ERR(rq)) { |
179 | gvt_err("fail to allocate gem request\n"); | 179 | gvt_err("fail to allocate gem request\n"); |
180 | workload->status = PTR_ERR(rq); | 180 | ret = PTR_ERR(rq); |
181 | return workload->status; | 181 | goto out; |
182 | } | 182 | } |
183 | 183 | ||
184 | gvt_dbg_sched("ring id %d get i915 gem request %p\n", ring_id, rq); | 184 | gvt_dbg_sched("ring id %d get i915 gem request %p\n", ring_id, rq); |
@@ -212,7 +212,8 @@ out: | |||
212 | if (ret) | 212 | if (ret) |
213 | workload->status = ret; | 213 | workload->status = ret; |
214 | 214 | ||
215 | i915_add_request_no_flush(rq); | 215 | if (!IS_ERR_OR_NULL(rq)) |
216 | i915_add_request_no_flush(rq); | ||
216 | mutex_unlock(&dev_priv->drm.struct_mutex); | 217 | mutex_unlock(&dev_priv->drm.struct_mutex); |
217 | return ret; | 218 | return ret; |
218 | } | 219 | } |
@@ -460,7 +461,8 @@ complete: | |||
460 | 461 | ||
461 | complete_current_workload(gvt, ring_id); | 462 | complete_current_workload(gvt, ring_id); |
462 | 463 | ||
463 | i915_gem_request_put(fetch_and_zero(&workload->req)); | 464 | if (workload->req) |
465 | i915_gem_request_put(fetch_and_zero(&workload->req)); | ||
464 | 466 | ||
465 | if (need_force_wake) | 467 | if (need_force_wake) |
466 | intel_uncore_forcewake_put(gvt->dev_priv, | 468 | intel_uncore_forcewake_put(gvt->dev_priv, |