[RFC v3 9/9] drm/i915/gvt: define weight according to vGPU type
Ping Gao
ping.a.gao at intel.com
Thu Mar 2 02:19:43 UTC 2017
Different vGPU type defined different maximum vGPU instances that
can be created, only the same vGPU type has the same vGPU resource
assignment.
If different type vGPUs been created at the same time, the vGPU
resource ratio between them is equal with the ratio of the maximum
instance of each.
Signed-off-by: Ping Gao <ping.a.gao at intel.com>
---
drivers/gpu/drm/i915/gvt/gvt.h | 5 +++++
drivers/gpu/drm/i915/gvt/kvmgt.c | 4 ++--
drivers/gpu/drm/i915/gvt/sched_policy.c | 1 +
drivers/gpu/drm/i915/gvt/vgpu.c | 8 ++++++++
4 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h
index f1057d1..bad7a40 100644
--- a/drivers/gpu/drm/i915/gvt/gvt.h
+++ b/drivers/gpu/drm/i915/gvt/gvt.h
@@ -151,6 +151,7 @@ struct intel_vgpu {
bool failsafe;
bool resetting;
void *sched_data;
+ struct intel_sched_ctl sched_ctl;
struct intel_vgpu_fence fence;
struct intel_vgpu_gm gm;
@@ -222,6 +223,8 @@ struct intel_vgpu_type {
unsigned int low_gm_size;
unsigned int high_gm_size;
unsigned int fence;
+
+ unsigned int weight;
};
struct intel_gvt {
@@ -329,6 +332,8 @@ struct intel_vgpu_creation_params {
__u64 fence_sz;
__s32 primary;
__u64 vgpu_id;
+
+ __u32 weight;
};
int intel_vgpu_alloc_resource(struct intel_vgpu *vgpu,
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 0f7f5d9..0b7ab62 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -295,10 +295,10 @@ static ssize_t description_show(struct kobject *kobj, struct device *dev,
return 0;
return sprintf(buf, "low_gm_size: %dMB\nhigh_gm_size: %dMB\n"
- "fence: %d\n",
+ "fence: %d\nweight: %d\n",
BYTES_TO_MB(type->low_gm_size),
BYTES_TO_MB(type->high_gm_size),
- type->fence);
+ type->fence, type->weight);
}
static MDEV_TYPE_ATTR_RO(available_instances);
diff --git a/drivers/gpu/drm/i915/gvt/sched_policy.c b/drivers/gpu/drm/i915/gvt/sched_policy.c
index 47b1c96..011ec7f 100644
--- a/drivers/gpu/drm/i915/gvt/sched_policy.c
+++ b/drivers/gpu/drm/i915/gvt/sched_policy.c
@@ -441,6 +441,7 @@ static int tbs_sched_init_vgpu(struct intel_vgpu *vgpu)
if (!data)
return -ENOMEM;
+ data->sched_ctl.weight = vgpu->sched_ctl.weight;
data->vgpu = vgpu;
INIT_LIST_HEAD(&data->list);
INIT_LIST_HEAD(&data->lru_list);
diff --git a/drivers/gpu/drm/i915/gvt/vgpu.c b/drivers/gpu/drm/i915/gvt/vgpu.c
index 3bb1161..4edafdc 100644
--- a/drivers/gpu/drm/i915/gvt/vgpu.c
+++ b/drivers/gpu/drm/i915/gvt/vgpu.c
@@ -76,6 +76,7 @@ int intel_gvt_init_vgpu_types(struct intel_gvt *gvt)
unsigned int num_types;
unsigned int i, low_avail, high_avail;
unsigned int min_low;
+ unsigned int com_multi = 1;
/* vGPU type name is defined as GVTg_Vx_y which contains
* physical GPU generation type and 'y' means maximum vGPU
@@ -110,6 +111,8 @@ int intel_gvt_init_vgpu_types(struct intel_gvt *gvt)
high_avail / gvt->types[i].high_gm_size);
gvt->types[i].avail_instance = gvt->types[i].max_instance;
+ com_multi *= gvt->types[i].max_instance;
+
if (IS_GEN8(gvt->dev_priv))
sprintf(gvt->types[i].name, "GVTg_V4_%u",
gvt->types[i].max_instance);
@@ -125,6 +128,9 @@ int intel_gvt_init_vgpu_types(struct intel_gvt *gvt)
gvt->types[i].high_gm_size, gvt->types[i].fence);
}
+ for (i = 0; i < num_types; ++i)
+ gvt->types[i].weight = com_multi / gvt->types[i].max_instance;
+
gvt->num_types = i;
return 0;
}
@@ -277,6 +283,7 @@ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt,
vgpu->id = ret;
vgpu->handle = param->handle;
vgpu->gvt = gvt;
+ vgpu->sched_ctl.weight = param->weight;
bitmap_zero(vgpu->tlb_handle_pending, I915_NUM_ENGINES);
intel_vgpu_init_cfg_space(vgpu, param->primary);
@@ -363,6 +370,7 @@ struct intel_vgpu *intel_gvt_create_vgpu(struct intel_gvt *gvt,
param.low_gm_sz = type->low_gm_size;
param.high_gm_sz = type->high_gm_size;
param.fence_sz = type->fence;
+ param.weight = type->weight;
/* XXX current param based on MB */
param.low_gm_sz = BYTES_TO_MB(param.low_gm_sz);
--
2.7.4
More information about the intel-gvt-dev
mailing list