drm/i915/gvt: release shadow batch buffer and wa_ctx before destroy one workload

Submitted by Weinan Li on Jan. 22, 2019, 5:46 a.m.

Details

Message ID 1548135987-8894-1-git-send-email-weinan.z.li@intel.com
State New
Headers show
Series "drm/i915/gvt: release shadow batch buffer and wa_ctx before destroy one workload" ( rev: 1 ) in Intel GVT devel

Not browsing as part of any series.

Commit Message

Weinan Li Jan. 22, 2019, 5:46 a.m.
GVT-g will shadow the privilege batch buffer and the indirect context
during command scan, move the release process into
intel_vgpu_destroy_workload() to ensure the resources are recycled
properly.

Fixes: 0cce2823ed37 ("drm/i915/gvt/kvmgt:Refine error handling for prepare_execlist_workload")

Signed-off-by: Weinan Li <weinan.z.li@intel.com>
---
 drivers/gpu/drm/i915/gvt/scheduler.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c
index 95f2547..1bb8f93 100644
--- a/drivers/gpu/drm/i915/gvt/scheduler.c
+++ b/drivers/gpu/drm/i915/gvt/scheduler.c
@@ -333,6 +333,9 @@  static void release_shadow_wa_ctx(struct intel_shadow_wa_ctx *wa_ctx)
 
 	i915_gem_object_unpin_map(wa_ctx->indirect_ctx.obj);
 	i915_gem_object_put(wa_ctx->indirect_ctx.obj);
+
+	wa_ctx->indirect_ctx.obj = NULL;
+	wa_ctx->indirect_ctx.shadow_va = NULL;
 }
 
 static int set_context_ppgtt_from_shadow(struct intel_vgpu_workload *workload,
@@ -912,11 +915,6 @@  static void complete_current_workload(struct intel_gvt *gvt, int ring_id)
 
 	list_del_init(&workload->list);
 
-	if (!workload->status) {
-		release_shadow_batch_buffer(workload);
-		release_shadow_wa_ctx(&workload->wa_ctx);
-	}
-
 	if (workload->status || (vgpu->resetting_eng & ENGINE_MASK(ring_id))) {
 		/* if workload->status is not successful means HW GPU
 		 * has occurred GPU hang or something wrong with i915/GVT,
@@ -1282,6 +1280,9 @@  void intel_vgpu_destroy_workload(struct intel_vgpu_workload *workload)
 {
 	struct intel_vgpu_submission *s = &workload->vgpu->submission;
 
+	release_shadow_batch_buffer(workload);
+	release_shadow_wa_ctx(&workload->wa_ctx);
+
 	if (workload->shadow_mm)
 		intel_vgpu_mm_put(workload->shadow_mm);
 

Comments

On 2019.01.22 13:46:27 +0800, Weinan Li wrote:
> GVT-g will shadow the privilege batch buffer and the indirect context
> during command scan, move the release process into
> intel_vgpu_destroy_workload() to ensure the resources are recycled
> properly.
> 
> Fixes: 0cce2823ed37 ("drm/i915/gvt/kvmgt:Refine error handling for prepare_execlist_workload")
> 
> Signed-off-by: Weinan Li <weinan.z.li@intel.com>
> ---

Looks good to me.

Reviewed-by: Zhenyu Wang <zhenyuw@linux.intel.com>

Thanks for the fix!

>  drivers/gpu/drm/i915/gvt/scheduler.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c
> index 95f2547..1bb8f93 100644
> --- a/drivers/gpu/drm/i915/gvt/scheduler.c
> +++ b/drivers/gpu/drm/i915/gvt/scheduler.c
> @@ -333,6 +333,9 @@ static void release_shadow_wa_ctx(struct intel_shadow_wa_ctx *wa_ctx)
>  
>  	i915_gem_object_unpin_map(wa_ctx->indirect_ctx.obj);
>  	i915_gem_object_put(wa_ctx->indirect_ctx.obj);
> +
> +	wa_ctx->indirect_ctx.obj = NULL;
> +	wa_ctx->indirect_ctx.shadow_va = NULL;
>  }
>  
>  static int set_context_ppgtt_from_shadow(struct intel_vgpu_workload *workload,
> @@ -912,11 +915,6 @@ static void complete_current_workload(struct intel_gvt *gvt, int ring_id)
>  
>  	list_del_init(&workload->list);
>  
> -	if (!workload->status) {
> -		release_shadow_batch_buffer(workload);
> -		release_shadow_wa_ctx(&workload->wa_ctx);
> -	}
> -
>  	if (workload->status || (vgpu->resetting_eng & ENGINE_MASK(ring_id))) {
>  		/* if workload->status is not successful means HW GPU
>  		 * has occurred GPU hang or something wrong with i915/GVT,
> @@ -1282,6 +1280,9 @@ void intel_vgpu_destroy_workload(struct intel_vgpu_workload *workload)
>  {
>  	struct intel_vgpu_submission *s = &workload->vgpu->submission;
>  
> +	release_shadow_batch_buffer(workload);
> +	release_shadow_wa_ctx(&workload->wa_ctx);
> +
>  	if (workload->shadow_mm)
>  		intel_vgpu_mm_put(workload->shadow_mm);
>  
> -- 
> 1.9.1
> 
> _______________________________________________
> intel-gvt-dev mailing list
> intel-gvt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev