[PATCH v4 2/9] drm/i915/gvt: create an idle vGPU
Tian, Kevin
kevin.tian at intel.com
Tue Mar 14 10:15:13 UTC 2017
> From: Ping Gao
> Sent: Wednesday, March 8, 2017 2:24 PM
>
> vGPU execution time is given by scheduler, it decide the resource vGPU could
given->allocated
what's difference between execution time and resource? If same meaning
just keep the former part.
> take. Creating an idle vGPU mainly used to help time slice usage calculation
'is' mainly
> and worked as a time slice pool to consume the time slice that active vGPU
> no need. Besides that it also helpful to handle some special case.
I guess above can be simplified like below:
vGPU execution time is allocated by scheduler. To account for non-allocated
free cycles, we create an idle vGPU as the placeholder similar to idle task
concept, which is useful to handle some corner cases in scheduling policy.
>
> 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..996467d 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_idle_vgpu(gvt->idle_vgpu);
does idle_vgpu also have an idr? If yes, should destroy idle
vgpu before idr_destroy.
> +
> 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_idle_vgpu(gvt);
> + if (IS_ERR(vgpu)) {
> + ret = PTR_ERR(vgpu);
> + gvt_err("failed to create intel idle vgpu: %d\n", ret);
"Failed to create idle vGPU"
> + goto out_clean_types;
> + }
> + gvt->idle_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 1839456..f3f5678 100644
> --- a/drivers/gpu/drm/i915/gvt/gvt.h
> +++ b/drivers/gpu/drm/i915/gvt/gvt.h
> @@ -237,6 +237,7 @@ struct intel_gvt {
> struct intel_vgpu_type *types;
> unsigned int num_types;
> atomic_t num_vgpu_sched;
> + struct intel_vgpu *idle_vgpu;
>
> struct task_struct *service_thread;
> wait_queue_head_t service_thread_wq;
> @@ -378,6 +379,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_idle_vgpu(struct intel_gvt *gvt);
> +void intel_gvt_destroy_idle_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 f3bec5a..945327b 100644
> --- a/drivers/gpu/drm/i915/gvt/vgpu.c
> +++ b/drivers/gpu/drm/i915/gvt/vgpu.c
> @@ -216,6 +216,57 @@ void intel_gvt_destroy_vgpu(struct intel_vgpu
> *vgpu)
> mutex_unlock(&gvt->lock);
> }
>
> +/**
> + * intel_gvt_create_idle_vgpu - create an idle virtual GPU
> + * @gvt: GVT device
> + *
> + * This function is called when user wants to create an idle virtual GPU.
> + *
> + * Returns:
> + * pointer to intel_vgpu, error pointer if failed.
> + */
> +struct intel_vgpu *intel_gvt_create_idle_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;
please define a macro. Then use that macro as start in idr_alloc
for other vgpus.
> + 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 an idle virtual GPU
> + * @vgpu: virtual GPU
> + *
> + * This function is called when user wants to destroy an idle virtual GPU.
> + *
> + */
> +void intel_gvt_destroy_idle_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