Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Zhenyu Wang <zhenyuw@linux.intel.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Max Gurtovoy <mgurtovoy@nvidia.com>,
	"Raj, Ashok" <ashok.raj@intel.com>,
	David Airlie <airlied@linux.ie>,
	Leon Romanovsky <leonro@nvidia.com>,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	Dan Williams <dan.j.williams@intel.com>,
	intel-gvt-dev@lists.freedesktop.org,
	Christoph Hellwig <hch@lst.de>, Tarun Gupta <targupta@nvidia.com>
Subject: Re: [Intel-gfx] [PATCH v2 16/18] vfio/gvt: Use mdev_get_type_group_id()
Date: Mon, 12 Apr 2021 15:30:06 +0800	[thread overview]
Message-ID: <20210412073006.GD1551@zhen-hp.sh.intel.com> (raw)
In-Reply-To: <16-v2-d36939638fc6+d54-vfio2_jgg@nvidia.com>


[-- Attachment #1.1: Type: text/plain, Size: 4123 bytes --]

On 2021.04.06 16:40:39 -0300, Jason Gunthorpe wrote:
> 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>
> ---

Reviewed-by: Zhenyu Wang <zhenyuw@linux.intel.com>

For two gvt specific changes in this series, it's better to just merge through
vfio tree.

Thanks

>  drivers/gpu/drm/i915/gvt/gvt.c   | 24 +++++++-----------------
>  drivers/gpu/drm/i915/gvt/gvt.h   |  4 ++--
>  drivers/gpu/drm/i915/gvt/kvmgt.c |  5 ++---
>  3 files changed, 11 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/gvt.c b/drivers/gpu/drm/i915/gvt/gvt.c
> index d1d8ee4a5f16a3..4b47a18e9dfa0f 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;
>  
> diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h
> index 03c993d68f105a..0cf480f42850d2 100644
> --- a/drivers/gpu/drm/i915/gvt/gvt.h
> +++ b/drivers/gpu/drm/i915/gvt/gvt.h
> @@ -569,8 +569,8 @@ struct intel_gvt_ops {
>  	void (*vgpu_reset)(struct intel_vgpu *);
>  	void (*vgpu_activate)(struct intel_vgpu *);
>  	void (*vgpu_deactivate)(struct intel_vgpu *);
> -	struct intel_vgpu_type *(*gvt_find_vgpu_type)(struct intel_gvt *gvt,
> -			const char *name);
> +	struct intel_vgpu_type *(*gvt_find_vgpu_type)(
> +		struct intel_gvt *gvt, unsigned int type_group_id);
>  	bool (*get_gvt_attrs)(struct attribute_group ***intel_vgpu_type_groups);
>  	int (*vgpu_query_plane)(struct intel_vgpu *vgpu, void *);
>  	int (*vgpu_get_dmabuf)(struct intel_vgpu *vgpu, unsigned int);
> diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
> index b4348256ae9591..16e1e4a38aa1f6 100644
> --- a/drivers/gpu/drm/i915/gvt/kvmgt.c
> +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
> @@ -700,10 +700,9 @@ static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev)
>  	pdev = mdev_parent_dev(mdev);
>  	gvt = kdev_to_i915(pdev)->gvt;
>  
> -	type = intel_gvt_ops->gvt_find_vgpu_type(gvt, kobject_name(kobj));
> +	type = intel_gvt_ops->gvt_find_vgpu_type(gvt,
> +						 mdev_get_type_group_id(mdev));
>  	if (!type) {
> -		gvt_vgpu_err("failed to find type %s to create\n",
> -						kobject_name(kobj));
>  		ret = -EINVAL;
>  		goto out;
>  	}
> -- 
> 2.31.1
> 

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2021-04-12  7:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-06 19:40 [Intel-gfx] [PATCH v2 00/18] Make vfio_mdev type safe Jason Gunthorpe
2021-04-06 19:40 ` [Intel-gfx] [PATCH v2 15/18] vfio/gvt: Make DRM_I915_GVT depend on VFIO_MDEV Jason Gunthorpe
2021-04-12  7:27   ` Zhenyu Wang
2021-04-06 19:40 ` [Intel-gfx] [PATCH v2 16/18] vfio/gvt: Use mdev_get_type_group_id() Jason Gunthorpe
2021-04-12  7:30   ` Zhenyu Wang [this message]
2021-04-06 19:40 ` [Intel-gfx] [PATCH v2 17/18] vfio/mdev: Remove kobj from mdev_parent_ops->create() Jason Gunthorpe
2021-04-06 19:40 ` [Intel-gfx] [PATCH v2 18/18] vfio/mdev: Correct the function signatures for the mdev_type_attributes Jason Gunthorpe
2021-04-14 18:17 ` [Intel-gfx] [PATCH v2 00/18] Make vfio_mdev type safe Alex Williamson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210412073006.GD1551@zhen-hp.sh.intel.com \
    --to=zhenyuw@linux.intel.com \
    --cc=airlied@linux.ie \
    --cc=ashok.raj@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hch@lst.de \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-gvt-dev@lists.freedesktop.org \
    --cc=jgg@nvidia.com \
    --cc=leonro@nvidia.com \
    --cc=mgurtovoy@nvidia.com \
    --cc=targupta@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox