[PATCH 2/6] drm/i915/gvt: Add error handling for intel_gvt_scan_and_shadow_workload
Zhenyu Wang
zhenyuw at linux.intel.com
Fri Aug 11 02:18:25 UTC 2017
On 2017.08.10 23:31:36 +0800, fred gao wrote:
> When an error occurs after shadow_indirect_ctx, this patch is to do the
> proper cleanup and rollback to the original states for shadowed indirect
> context before the workload is abandoned.
>
> v2:
> - split the mixed several error paths for better review. (Zhenyu)
>
> v3:
> - no return check for clean up functions. (Changbin)
>
> v4:
> - expose and reuse the existing release_shadow_wa_ctx. (Zhenyu)
>
> Signed-off-by: fred gao <fred.gao at intel.com>
> ---
> drivers/gpu/drm/i915/gvt/execlist.c | 2 +-
> drivers/gpu/drm/i915/gvt/execlist.h | 3 +++
> drivers/gpu/drm/i915/gvt/scheduler.c | 10 ++++++----
> 3 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gvt/execlist.c b/drivers/gpu/drm/i915/gvt/execlist.c
> index 1e2c277..930768a 100644
> --- a/drivers/gpu/drm/i915/gvt/execlist.c
> +++ b/drivers/gpu/drm/i915/gvt/execlist.c
> @@ -489,7 +489,7 @@ static void release_shadow_batch_buffer(struct intel_vgpu_workload *workload)
> }
> }
>
> -static void release_shadow_wa_ctx(struct intel_shadow_wa_ctx *wa_ctx)
> +void release_shadow_wa_ctx(struct intel_shadow_wa_ctx *wa_ctx)
> {
> if (!wa_ctx->indirect_ctx.obj)
> return;
> diff --git a/drivers/gpu/drm/i915/gvt/execlist.h b/drivers/gpu/drm/i915/gvt/execlist.h
> index 7eced40..c7a9a29 100644
> --- a/drivers/gpu/drm/i915/gvt/execlist.h
> +++ b/drivers/gpu/drm/i915/gvt/execlist.h
> @@ -176,6 +176,9 @@ struct intel_vgpu_execlist {
> struct intel_vgpu_elsp_dwords elsp_dwords;
> };
>
> +struct intel_shadow_wa_ctx;
> +void release_shadow_wa_ctx(struct intel_shadow_wa_ctx *wa_ctx);
> +
Looks more clean way is to move that release function to scheduler.c and
call it in execlist.c.
> void intel_vgpu_clean_execlist(struct intel_vgpu *vgpu);
>
> int intel_vgpu_init_execlist(struct intel_vgpu *vgpu);
> diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c
> index 43022d3..aeb99cdac 100644
> --- a/drivers/gpu/drm/i915/gvt/scheduler.c
> +++ b/drivers/gpu/drm/i915/gvt/scheduler.c
> @@ -283,18 +283,18 @@ int intel_gvt_scan_and_shadow_workload(struct intel_vgpu_workload *workload)
> if (IS_ERR(ring)) {
> ret = PTR_ERR(ring);
> gvt_vgpu_err("fail to pin shadow context\n");
> - goto out;
> + goto err_shadow;
> }
>
> ret = populate_shadow_context(workload);
> if (ret)
> - goto out;
> + goto err_shadow;
>
> 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 out;
> + goto err_shadow;
> }
>
> gvt_dbg_sched("ring id %d get i915 gem request %p\n", ring_id, rq);
> @@ -302,9 +302,11 @@ 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 out;
> + goto err_shadow;
> workload->shadowed = true;
>
> +err_shadow:
> + release_shadow_wa_ctx(&workload->wa_ctx);
> out:
> return 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/4a5ee706/attachment-0001.sig>
More information about the intel-gvt-dev
mailing list