[PATCH v1 4/4] drm/i915/gvt: Select vgpu type by deviceID in hvm cfg file
fred gao
fred.gao at intel.com
Wed Sep 13 08:43:05 UTC 2017
The vgpu type will be parsed through the device ID in hwm cfg,
then can be passed into kernel.
The old parameters such as aperture_sz, gm_sz, fence_sz for
finding a proper type are removed in this patch.
Signed-off-by: fred gao <fred.gao at intel.com>
---
drivers/gpu/drm/i915/gvt/xengt.c | 49 ++++++++--------------------------------
drivers/gpu/drm/i915/gvt/xengt.h | 4 +---
2 files changed, 10 insertions(+), 43 deletions(-)
diff --git a/drivers/gpu/drm/i915/gvt/xengt.c b/drivers/gpu/drm/i915/gvt/xengt.c
index 4cab2d8..79655a0 100644
--- a/drivers/gpu/drm/i915/gvt/xengt.c
+++ b/drivers/gpu/drm/i915/gvt/xengt.c
@@ -127,24 +127,6 @@ static struct kobj_type xengt_ctrl_ktype = {
.default_attrs = xengt_ctrl_attrs,
};
-static struct intel_vgpu_type *xengt_choose_vgpu_type(
- struct xengt_hvm_params *vp)
-{
- struct intel_vgpu_type *vgpu_type;
- unsigned int i;
-
- for (i = 0; i < xengt_priv.gvt->num_types; i++) {
- vgpu_type = &xengt_priv.gvt->types[i];
- if ((vgpu_type->low_gm_size >> 20) == vp->aperture_sz) {
- gvt_dbg_core("choose vgpu type:%d\n", i);
- return vgpu_type;
- }
- }
-
- gvt_err("specify a wrong low_gm_sz in hvm.cfg: %d\n", vp->aperture_sz);
- return NULL;
-}
-
static int xengt_sysfs_add_instance(struct xengt_hvm_params *vp)
{
int ret = 0;
@@ -152,7 +134,7 @@ static int xengt_sysfs_add_instance(struct xengt_hvm_params *vp)
struct xengt_hvm_dev *info;
struct intel_vgpu_type *type;
- type = xengt_choose_vgpu_type(vp);
+ type = intel_gvt_ops->gvt_find_vgpu_type(xengt_priv.gvt, vp->type_name);
if (type == NULL) {
gvt_err("choose vgpu type failed");
return -EINVAL;
@@ -243,37 +225,24 @@ static ssize_t xengt_sysfs_instance_manage(struct kobject *kobj,
int param_cnt;
char param_str[64];
int rc;
- int high_gm_sz;
- int low_gm_sz;
/* We expect the param_str should be vmid,a,b,c (where the guest
* wants a MB aperture and b MB gm, and c fence registers) or -vmid
* (where we want to release the vgt instance).
*/
(void)sscanf(buf, "%63s", param_str);
- param_cnt = sscanf(param_str, "%d,%d,%d,%d,%d,%d", &vp.vm_id,
- &low_gm_sz, &high_gm_sz, &vp.fence_sz, &vp.gvt_primary,
- &vp.cap);
- vp.aperture_sz = low_gm_sz;
- vp.gm_sz = high_gm_sz + low_gm_sz;
+ param_cnt = sscanf(param_str, "%d,%d,%d,%s", &vp.vm_id,
+ &vp.gvt_primary, &vp.cap, vp.type_name);
if (param_cnt == 1) {
if (vp.vm_id >= 0)
return -EINVAL;
- } else if (param_cnt == 4 || param_cnt == 5 || param_cnt == 6) {
- if (!(vp.vm_id > 0 && vp.aperture_sz > 0 &&
- vp.aperture_sz <= vp.gm_sz && vp.fence_sz > 0))
- return -EINVAL;
+ } else if (param_cnt == 4) {
- if (param_cnt == 5 || param_cnt == 6) {
- /* -1/0/1 means: not-specified, non-primary, primary */
- if (vp.gvt_primary < -1 || vp.gvt_primary > 1)
- return -EINVAL;
- if (vp.cap < 0 || vp.cap > 100)
- return -EINVAL;
- } else {
- vp.cap = 0; /* default 0 means no upper cap. */
- vp.gvt_primary = -1; /* no valid value specified. */
- }
+ /* -1/0/1 means: not-specified, non-primary, primary */
+ if (vp.gvt_primary < -1 || vp.gvt_primary > 1)
+ return -EINVAL;
+ if (vp.cap < 0 || vp.cap > 100)
+ return -EINVAL;
} else
return -EINVAL;
diff --git a/drivers/gpu/drm/i915/gvt/xengt.h b/drivers/gpu/drm/i915/gvt/xengt.h
index 0f5b660..232dde6 100644
--- a/drivers/gpu/drm/i915/gvt/xengt.h
+++ b/drivers/gpu/drm/i915/gvt/xengt.h
@@ -48,15 +48,13 @@ struct xengt_hvm_dev {
struct xengt_hvm_params {
int vm_id;
- int aperture_sz; /* in MB */
- int gm_sz; /* in MB */
- int fence_sz;
int cap;
/*
* 0/1: config the vgt device as secondary/primary VGA,
* -1: means the ioemu doesn't supply a value
*/
int gvt_primary;
+ char type_name[16];
};
/*
--
2.7.4
More information about the intel-gvt-dev
mailing list