[PATCH v2 2/9] drm/i915/gvt: create a dummy vGPU

Tian, Kevin kevin.tian at intel.com
Tue Feb 14 08:49:06 UTC 2017


> From: Ping Gao
> Sent: Tuesday, February 14, 2017 12:26 PM
> 
> vGPU execution time is given by scheduler, it decide the resource
> vGPU could take. Creating a dummy vGPU mainly used to help time
> slice usage calculation and work as a time slice pool to consume
> the time slice that real vGPU no need. Besides that it also helpful
> to handle some special case.

do we need it even for weight-based scheduling?

think calling it idle-vGPU might be more meaningful - similar to idle
vCPU in hypervisor and idle process in OS. :)

> 
> Signed-off-by: Ping Gao <ping.a.gao at intel.com>
> ---
>  drivers/gpu/drm/i915/gvt/gvt.c  | 11 +++++++++
>  drivers/gpu/drm/i915/gvt/gvt.h  |  3 +++
>  drivers/gpu/drm/i915/gvt/vgpu.c | 51
> +++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 65 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/gvt.c b/drivers/gpu/drm/i915/gvt/gvt.c
> index 3e8c30f..7cd23dc 100644
> --- a/drivers/gpu/drm/i915/gvt/gvt.c
> +++ b/drivers/gpu/drm/i915/gvt/gvt.c
> @@ -201,6 +201,8 @@ void intel_gvt_clean_device(struct drm_i915_private *dev_priv)
> 
>  	idr_destroy(&gvt->vgpu_idr);
> 
> +	intel_gvt_destroy_dummy_vgpu(gvt->dummy_vgpu);
> +
>  	kfree(dev_priv->gvt);
>  	dev_priv->gvt = NULL;
>  }
> @@ -219,6 +221,7 @@ void intel_gvt_clean_device(struct drm_i915_private *dev_priv)
>  int intel_gvt_init_device(struct drm_i915_private *dev_priv)
>  {
>  	struct intel_gvt *gvt;
> +	struct intel_vgpu *vgpu;
>  	int ret;
> 
>  	/*
> @@ -291,6 +294,14 @@ int intel_gvt_init_device(struct drm_i915_private *dev_priv)
>  		goto out_clean_types;
>  	}
> 
> +	vgpu = intel_gvt_create_dummy_vgpu(gvt);
> +	if (IS_ERR_OR_NULL(vgpu)) {
> +		ret = vgpu == NULL ? -EFAULT : PTR_ERR(vgpu);

not readable. please split.

> +		gvt_err("failed to create intel dummy vgpu: %d\n", ret);
> +		goto out_clean_types;
> +	}
> +	gvt->dummy_vgpu = vgpu;
> +
>  	gvt_dbg_core("gvt device initialization is done\n");
>  	dev_priv->gvt = gvt;
>  	return 0;
> diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h
> index dae157e..78cbf3c 100644
> --- a/drivers/gpu/drm/i915/gvt/gvt.h
> +++ b/drivers/gpu/drm/i915/gvt/gvt.h
> @@ -235,6 +235,7 @@ struct intel_gvt {
>  	struct intel_vgpu_type *types;
>  	unsigned int num_types;
>  	unsigned int num_vgpu_sched;
> +	struct intel_vgpu *dummy_vgpu;
> 
>  	struct task_struct *service_thread;
>  	wait_queue_head_t service_thread_wq;
> @@ -375,6 +376,8 @@ static inline void intel_vgpu_write_pci_bar(struct intel_vgpu
> *vgpu,
>  int intel_gvt_init_vgpu_types(struct intel_gvt *gvt);
>  void intel_gvt_clean_vgpu_types(struct intel_gvt *gvt);
> 
> +struct intel_vgpu *intel_gvt_create_dummy_vgpu(struct intel_gvt *gvt);
> +void intel_gvt_destroy_dummy_vgpu(struct intel_vgpu *vgpu);
>  struct intel_vgpu *intel_gvt_create_vgpu(struct intel_gvt *gvt,
>  					 struct intel_vgpu_type *type);
>  void intel_gvt_destroy_vgpu(struct intel_vgpu *vgpu);
> diff --git a/drivers/gpu/drm/i915/gvt/vgpu.c b/drivers/gpu/drm/i915/gvt/vgpu.c
> index 67d471c..2b0fd13 100644
> --- a/drivers/gpu/drm/i915/gvt/vgpu.c
> +++ b/drivers/gpu/drm/i915/gvt/vgpu.c
> @@ -203,6 +203,57 @@ void intel_gvt_destroy_vgpu(struct intel_vgpu *vgpu)
>  	mutex_unlock(&gvt->lock);
>  }
> 
> +/**
> + * intel_gvt_create_dummy vgpu - create a dummy virtual GPU
> + * @gvt: GVT device
> + *
> + * This function is called when user wants to create a dummy virtual GPU.
> + *
> + * Returns:
> + * pointer to intel_vgpu, error pointer if failed.
> + */
> +struct intel_vgpu *intel_gvt_create_dummy_vgpu(struct intel_gvt *gvt)
> +{
> +	struct intel_vgpu *vgpu;
> +	enum intel_engine_id i;
> +	int ret;
> +
> +	vgpu = vzalloc(sizeof(*vgpu));
> +	if (!vgpu)
> +		return ERR_PTR(-ENOMEM);
> +
> +	vgpu->id = 0;
> +	vgpu->gvt = gvt;
> +
> +	for (i = 0; i < I915_NUM_ENGINES; i++)
> +		INIT_LIST_HEAD(&vgpu->workload_q_head[i]);
> +
> +	ret = intel_vgpu_init_sched_policy(vgpu);
> +	if (ret)
> +		goto out_free_vgpu;
> +
> +	vgpu->active = false;
> +
> +	return vgpu;
> +
> +out_free_vgpu:
> +	vfree(vgpu);
> +	return ERR_PTR(ret);
> +}
> +
> +/**
> + * intel_gvt_destroy_vgpu - destroy a dummy virtual GPU
> + * @vgpu: virtual GPU
> + *
> + * This function is called when user wants to destroy a dummy virtual GPU.
> + *
> + */
> +void intel_gvt_destroy_dummy_vgpu(struct intel_vgpu *vgpu)
> +{
> +	intel_vgpu_clean_sched_policy(vgpu);
> +	vfree(vgpu);
> +}
> +
>  static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt,
>  		struct intel_vgpu_creation_params *param)
>  {
> --
> 2.7.4
> 
> _______________________________________________
> intel-gvt-dev mailing list
> intel-gvt-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev


More information about the intel-gvt-dev mailing list