[Intel-gfx] [PATCH v2] drm/i915/gvt: Stop waiting whilst holding struct_mutex

Zhenyu Wang zhenyuw at linux.intel.com
Wed Oct 19 09:47:29 UTC 2016


On 2016.10.19 10:14:39 +0100, Chris Wilson wrote:
> For whatever reason, the gvt scheduler runs synchronously. At the very
> least, lets run synchronously without holding the struct_mutex.
> 
> v2: cut'n'paste mutex_lock instead of unlock.
> Replace long hold of struct_mutex with a mutex to serialise the worker
> threads.
> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

This looks ok to me, but let me test it with VM first to ensure
the behavior is expected.

Thanks

> ---
>  drivers/gpu/drm/i915/gvt/scheduler.c | 22 +++++++++++++---------
>  1 file changed, 13 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c
> index 4cedd3274da7..55f8ed7d7be5 100644
> --- a/drivers/gpu/drm/i915/gvt/scheduler.c
> +++ b/drivers/gpu/drm/i915/gvt/scheduler.c
> @@ -390,6 +390,8 @@ struct workload_thread_param {
>  	int ring_id;
>  };
>  
> +static DEFINE_MUTEX(scheduler_mutex);
> +
>  static int workload_thread(void *priv)
>  {
>  	struct workload_thread_param *p = (struct workload_thread_param *)priv;
> @@ -414,17 +416,14 @@ static int workload_thread(void *priv)
>  		if (kthread_should_stop())
>  			break;
>  
> +		mutex_lock(&scheduler_mutex);
> +
>  		gvt_dbg_sched("ring id %d next workload %p vgpu %d\n",
>  				workload->ring_id, workload,
>  				workload->vgpu->id);
>  
>  		intel_runtime_pm_get(gvt->dev_priv);
>  
> -		/*
> -		 * Always take i915 big lock first
> -		 */
> -		mutex_lock(&gvt->dev_priv->drm.struct_mutex);
> -
>  		gvt_dbg_sched("ring id %d will dispatch workload %p\n",
>  				workload->ring_id, workload);
>  
> @@ -432,7 +431,10 @@ static int workload_thread(void *priv)
>  			intel_uncore_forcewake_get(gvt->dev_priv,
>  					FORCEWAKE_ALL);
>  
> +		mutex_lock(&gvt->dev_priv->drm.struct_mutex);
>  		ret = dispatch_workload(workload);
> +		mutex_unlock(&gvt->dev_priv->drm.struct_mutex);
> +
>  		if (ret) {
>  			gvt_err("fail to dispatch workload, skip\n");
>  			goto complete;
> @@ -442,8 +444,7 @@ static int workload_thread(void *priv)
>  				workload->ring_id, workload);
>  
>  		workload->status = i915_wait_request(workload->req,
> -						     I915_WAIT_LOCKED,
> -						     NULL, NULL);
> +						     0, NULL, NULL);
>  		if (workload->status != 0)
>  			gvt_err("fail to wait workload, skip\n");
>  
> @@ -451,15 +452,18 @@ static int workload_thread(void *priv)
>  		gvt_dbg_sched("will complete workload %p\n, status: %d\n",
>  				workload, workload->status);
>  
> +		mutex_lock(&gvt->dev_priv->drm.struct_mutex);
>  		complete_current_workload(gvt, ring_id);
> +		mutex_unlock(&gvt->dev_priv->drm.struct_mutex);
>  
>  		if (need_force_wake)
>  			intel_uncore_forcewake_put(gvt->dev_priv,
>  					FORCEWAKE_ALL);
>  
> -		mutex_unlock(&gvt->dev_priv->drm.struct_mutex);
> -
>  		intel_runtime_pm_put(gvt->dev_priv);
> +
> +		mutex_unlock(&scheduler_mutex);
> +
>  	}
>  	return 0;
>  }
> -- 
> 2.9.3
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
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: 163 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/intel-gfx/attachments/20161019/a6be4417/attachment-0001.sig>


More information about the Intel-gfx mailing list