提交 53d6f812 编写于 作者: Z Zhenyu Wang

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: 90d27a1b ("drm/i915/gvt: fix deadlock in workload_thread")
Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Pei Zhang <pei.zhang@intel.com>
Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
上级 550dd77e
...@@ -177,8 +177,8 @@ static int dispatch_workload(struct intel_vgpu_workload *workload) ...@@ -177,8 +177,8 @@ static int dispatch_workload(struct intel_vgpu_workload *workload)
rq = i915_gem_request_alloc(dev_priv->engine[ring_id], shadow_ctx); rq = i915_gem_request_alloc(dev_priv->engine[ring_id], shadow_ctx);
if (IS_ERR(rq)) { if (IS_ERR(rq)) {
gvt_err("fail to allocate gem request\n"); gvt_err("fail to allocate gem request\n");
workload->status = PTR_ERR(rq); ret = PTR_ERR(rq);
return workload->status; goto out;
} }
gvt_dbg_sched("ring id %d get i915 gem request %p\n", ring_id, rq); gvt_dbg_sched("ring id %d get i915 gem request %p\n", ring_id, rq);
...@@ -212,7 +212,8 @@ static int dispatch_workload(struct intel_vgpu_workload *workload) ...@@ -212,7 +212,8 @@ static int dispatch_workload(struct intel_vgpu_workload *workload)
if (ret) if (ret)
workload->status = ret; workload->status = ret;
i915_add_request_no_flush(rq); if (!IS_ERR_OR_NULL(rq))
i915_add_request_no_flush(rq);
mutex_unlock(&dev_priv->drm.struct_mutex); mutex_unlock(&dev_priv->drm.struct_mutex);
return ret; return ret;
} }
...@@ -460,7 +461,8 @@ static int workload_thread(void *priv) ...@@ -460,7 +461,8 @@ static int workload_thread(void *priv)
complete_current_workload(gvt, ring_id); complete_current_workload(gvt, ring_id);
i915_gem_request_put(fetch_and_zero(&workload->req)); if (workload->req)
i915_gem_request_put(fetch_and_zero(&workload->req));
if (need_force_wake) if (need_force_wake)
intel_uncore_forcewake_put(gvt->dev_priv, intel_uncore_forcewake_put(gvt->dev_priv,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册