[PATCH 5/6] drm/i915/gvt: Refine error handling in dispatch_workload
Zhenyu Wang
zhenyuw at linux.intel.com
Fri Aug 11 08:47:53 UTC 2017
On 2017.08.11 16:25:36 +0800, fred gao wrote:
> When an error occurs in dispatch_workload, this patch is to do the
> proper cleanup and rollback to the original states before the workload
> is abandoned.
>
> v2:
> - split the mixed several error paths for better review. (Zhenyu)
>
> v3:
> - original PTR_ERR(cs) is good and code cleanup. (Zhenyu)
>
> v4:
> - reuse the existing i915_add_request for error handling. (Zhenyu)
>
> Signed-off-by: fred gao <fred.gao at intel.com>
> ---
> drivers/gpu/drm/i915/gvt/scheduler.c | 29 ++++++++++++++++++++---------
> 1 file changed, 20 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c
> index 2846a82..f5f14d9 100644
> --- a/drivers/gpu/drm/i915/gvt/scheduler.c
> +++ b/drivers/gpu/drm/i915/gvt/scheduler.c
> @@ -272,13 +272,13 @@ int intel_gvt_scan_and_shadow_workload(struct intel_vgpu_workload *workload)
>
> ret = intel_gvt_scan_and_shadow_ringbuffer(workload);
> if (ret)
> - goto out;
> + goto err_scan;
>
> if ((workload->ring_id == RCS) &&
> (workload->wa_ctx.indirect_ctx.size != 0)) {
> ret = intel_gvt_scan_and_shadow_wa_ctx(&workload->wa_ctx);
> if (ret)
> - goto out;
> + goto err_scan;
> }
>
> /* pin shadow context by gvt even the shadow context will be pinned
> @@ -297,13 +297,13 @@ int intel_gvt_scan_and_shadow_workload(struct intel_vgpu_workload *workload)
>
> ret = populate_shadow_context(workload);
> if (ret)
> - goto err_shadow;
> + goto err_unpin;
>
> rq = i915_gem_request_alloc(dev_priv->engine[ring_id], shadow_ctx);
> if (IS_ERR(rq)) {
> gvt_vgpu_err("fail to allocate gem request\n");
> ret = PTR_ERR(rq);
> - goto err_shadow;
> + goto err_unpin;
> }
>
> gvt_dbg_sched("ring id %d get i915 gem request %p\n", ring_id, rq);
> @@ -311,13 +311,15 @@ int intel_gvt_scan_and_shadow_workload(struct intel_vgpu_workload *workload)
> workload->req = i915_gem_request_get(rq);
> ret = copy_workload_to_ring_buffer(workload);
> if (ret)
> - goto err_shadow;
> + goto err_unpin;
> workload->shadowed = true;
> return 0;
>
> +err_unpin:
> + engine->context_unpin(engine, shadow_ctx);
> err_shadow:
> release_shadow_wa_ctx(&workload->wa_ctx);
> -out:
> +err_scan:
> return ret;
> }
Should move this into 2/6 patch
>
> @@ -334,15 +336,24 @@ static int dispatch_workload(struct intel_vgpu_workload *workload)
>
> ret = intel_gvt_scan_and_shadow_workload(workload);
> if (ret)
> - goto out;
> + goto err_scan;
>
> if (workload->prepare) {
> ret = workload->prepare(workload);
> if (ret)
> - goto out;
> + goto err_shadow;
> }
>
> -out:
> +err_shadow:
> + if (ret) {
> + struct i915_gem_context *shadow_ctx;
> + struct intel_engine_cs *engine = dev_priv->engine[ring_id];
> +
> + shadow_ctx = workload->vgpu->shadow_ctx;
> + engine->context_unpin(engine, shadow_ctx);
> + release_shadow_wa_ctx(&workload->wa_ctx);
> + }
In 3/6 you've already handled error path of "prepare" call, why do anything extra?
> +err_scan:
> if (ret)
> workload->status = ret;
>
> --
> 2.7.4
>
> _______________________________________________
> intel-gvt-dev mailing list
> intel-gvt-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev
--
Open Source Technology Center, Intel ltd.
$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/intel-gvt-dev/attachments/20170811/a48ca745/attachment.sig>
More information about the intel-gvt-dev
mailing list