diff options
author | Jason Gunthorpe <jgg@nvidia.com> | 2021-04-06 22:40:39 +0300 |
---|---|---|
committer | Alex Williamson <alex.williamson@redhat.com> | 2021-04-12 19:36:00 +0300 |
commit | 383987fd15ba8f37bdc20994dadeb13df76342d6 (patch) | |
tree | 12377bd6d87875cd70941388554983e27fd1c212 /drivers/gpu/drm/i915/gvt/gvt.c | |
parent | 07e543f4f9d116d6b4240644191dee6388ef4a85 (diff) | |
download | linux-383987fd15ba8f37bdc20994dadeb13df76342d6.tar.xz |
vfio/gvt: Use mdev_get_type_group_id()
intel_gvt_init_vgpu_type_groups() makes gvt->types 1:1 with the
supported_type_groups array, so the type_group_id is also the index into
gvt->types. Use it directly and remove the string matching.
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Message-Id: <16-v2-d36939638fc6+d54-vfio2_jgg@nvidia.com>
Reviewed-by: Zhenyu Wang <zhenyuw@linux.intel.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/i915/gvt/gvt.c')
-rw-r--r-- | drivers/gpu/drm/i915/gvt/gvt.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/drivers/gpu/drm/i915/gvt/gvt.c b/drivers/gpu/drm/i915/gvt/gvt.c index d1d8ee4a5f16..4b47a18e9dfa 100644 --- a/drivers/gpu/drm/i915/gvt/gvt.c +++ b/drivers/gpu/drm/i915/gvt/gvt.c @@ -46,22 +46,12 @@ static const char * const supported_hypervisors[] = { [INTEL_GVT_HYPERVISOR_KVM] = "KVM", }; -static struct intel_vgpu_type *intel_gvt_find_vgpu_type(struct intel_gvt *gvt, - const char *name) +static struct intel_vgpu_type * +intel_gvt_find_vgpu_type(struct intel_gvt *gvt, unsigned int type_group_id) { - const char *driver_name = - dev_driver_string(&gvt->gt->i915->drm.pdev->dev); - int i; - - name += strlen(driver_name) + 1; - for (i = 0; i < gvt->num_types; i++) { - struct intel_vgpu_type *t = &gvt->types[i]; - - if (!strncmp(t->name, name, sizeof(t->name))) - return t; - } - - return NULL; + if (WARN_ON(type_group_id >= gvt->num_types)) + return NULL; + return &gvt->types[type_group_id]; } static ssize_t available_instances_show(struct kobject *kobj, @@ -71,7 +61,7 @@ static ssize_t available_instances_show(struct kobject *kobj, unsigned int num = 0; void *gvt = kdev_to_i915(dev)->gvt; - type = intel_gvt_find_vgpu_type(gvt, kobject_name(kobj)); + type = intel_gvt_find_vgpu_type(gvt, mtype_get_type_group_id(kobj)); if (!type) num = 0; else @@ -92,7 +82,7 @@ static ssize_t description_show(struct kobject *kobj, struct device *dev, struct intel_vgpu_type *type; void *gvt = kdev_to_i915(dev)->gvt; - type = intel_gvt_find_vgpu_type(gvt, kobject_name(kobj)); + type = intel_gvt_find_vgpu_type(gvt, mtype_get_type_group_id(kobj)); if (!type) return 0; |