[PATCH] drm/i915/gvt: Add mdev device attribute group

Zhenyu Wang zhenyuw at linux.intel.com
Wed Mar 8 08:42:12 UTC 2017


On 2017.03.08 16:19:48 +0800, Zhenyu Wang wrote:
> This adds initial attribute group for mdev to hold vGPU related
> for each mdev device, currently just vGPU id is shown.
> 
> Signed-off-by: Zhenyu Wang <zhenyuw at linux.intel.com>
> ---

As this will try to create gvt specific attrs directory for each mdev,
named for "vgpu" now, if anyone prefers other name like "intel_vgpu"?

>  drivers/gpu/drm/i915/gvt/kvmgt.c | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
> index 84d801638ede..1ce4c034d02b 100644
> --- a/drivers/gpu/drm/i915/gvt/kvmgt.c
> +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
> @@ -1144,8 +1144,40 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
>  	return 0;
>  }
>  
> +static ssize_t
> +vgpu_id_show(struct device *dev, struct device_attribute *attr,
> +	     char *buf)
> +{
> +	struct mdev_device *mdev = mdev_from_dev(dev);
> +
> +	if (mdev) {
> +		struct intel_vgpu *vgpu = (struct intel_vgpu *)
> +			mdev_get_drvdata(mdev);
> +		return sprintf(buf, "%d\n", vgpu->id);
> +	}
> +	return sprintf(buf, "\n");
> +}
> +
> +static DEVICE_ATTR_RO(vgpu_id);
> +
> +static struct attribute *intel_vgpu_attrs[] = {
> +	&dev_attr_vgpu_id.attr,
> +	NULL
> +};
> +
> +static const struct attribute_group intel_vgpu_group = {
> +	.name = "vgpu",
> +	.attrs = intel_vgpu_attrs,
> +};
> +
> +static const struct attribute_group *intel_vgpu_groups[] = {
> +	&intel_vgpu_group,
> +	NULL,
> +};
> +
>  static const struct mdev_parent_ops intel_vgpu_ops = {
>  	.supported_type_groups	= intel_vgpu_type_groups,
> +	.mdev_attr_groups       = intel_vgpu_groups,
>  	.create			= intel_vgpu_create,
>  	.remove			= intel_vgpu_remove,
>  
> -- 
> 2.11.0
> 
> _______________________________________________
> intel-gvt-dev mailing list
> intel-gvt-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev

-- 
Open Source Technology Center, Intel ltd.

$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 163 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/intel-gvt-dev/attachments/20170308/553d3647/attachment.sig>


More information about the intel-gvt-dev mailing list