[PATCH v2] drm/i915/gvt: Only pin/unpin intel_context along with workload

Zhenyu Wang zhenyuw at linux.intel.com
Mon Oct 19 08:12:52 UTC 2020


On 2020.10.16 13:40:59 +0800, Colin Xu wrote:
> One issue exposed after below commit with which the system will freeze
> at suspend after vGPU is created (no need to activate the vGPU).
> commit e6ba76480299 ("drm/i915: Remove i915->kernel_context")
> 
> Old implementation pin the intel_context at setup_submission and
> unpin it at clean_submission. So after some vGPU is created, the
> intel_context is always pinned there although no workload using it.
> It will then block i915 enter suspend state.
> 
> There is no need to pin it all the time. Pin/unpin it around workload
> lifecycle is more reasonable. After GVT enabled suspend/resume, the
> pinned intel_context will also get unpined when userspace put VM process
> into suspend state since all workloads are retired, then it's safe to
> unpin all intel_context for workloads created. So move the pin/unpin to
> create_workload and destroy_workload, while still keep the
> create/destroy in old place.
> 
> V2:
> Rebase.
> 
> Fixes: e6ba76480299 (drm/i915: Remove i915->kernel_context)
> Signed-off-by: Colin Xu <colin.xu at intel.com>
> ---

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

>  drivers/gpu/drm/i915/gvt/scheduler.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c
> index 1570eb8aa978..aed2ef6466a2 100644
> --- a/drivers/gpu/drm/i915/gvt/scheduler.c
> +++ b/drivers/gpu/drm/i915/gvt/scheduler.c
> @@ -1277,7 +1277,7 @@ void intel_vgpu_clean_submission(struct intel_vgpu *vgpu)
>  
>  	i915_context_ppgtt_root_restore(s, i915_vm_to_ppgtt(s->shadow[0]->vm));
>  	for_each_engine(engine, vgpu->gvt->gt, id)
> -		intel_context_unpin(s->shadow[id]);
> +		intel_context_put(s->shadow[id]);
>  
>  	kmem_cache_destroy(s->workloads);
>  }
> @@ -1369,11 +1369,6 @@ int intel_vgpu_setup_submission(struct intel_vgpu *vgpu)
>  			ce->ring = __intel_context_ring_size(ring_size);
>  		}
>  
> -		ret = intel_context_pin(ce);
> -		intel_context_put(ce);
> -		if (ret)
> -			goto out_shadow_ctx;
> -
>  		s->shadow[i] = ce;
>  	}
>  
> @@ -1405,7 +1400,6 @@ int intel_vgpu_setup_submission(struct intel_vgpu *vgpu)
>  		if (IS_ERR(s->shadow[i]))
>  			break;
>  
> -		intel_context_unpin(s->shadow[i]);
>  		intel_context_put(s->shadow[i]);
>  	}
>  	i915_vm_put(&ppgtt->vm);
> @@ -1479,6 +1473,7 @@ void intel_vgpu_destroy_workload(struct intel_vgpu_workload *workload)
>  {
>  	struct intel_vgpu_submission *s = &workload->vgpu->submission;
>  
> +	intel_context_unpin(s->shadow[workload->engine->id]);
>  	release_shadow_batch_buffer(workload);
>  	release_shadow_wa_ctx(&workload->wa_ctx);
>  
> @@ -1724,6 +1719,12 @@ intel_vgpu_create_workload(struct intel_vgpu *vgpu,
>  		return ERR_PTR(ret);
>  	}
>  
> +	ret = intel_context_pin(s->shadow[engine->id]);
> +	if (ret) {
> +		intel_vgpu_destroy_workload(workload);
> +		return ERR_PTR(ret);
> +	}
> +
>  	return workload;
>  }
>  
> -- 
> 2.28.0
> 
> _______________________________________________
> intel-gvt-dev mailing list
> intel-gvt-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev

-- 

$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/20201019/90a72409/attachment.sig>


More information about the intel-gvt-dev mailing list