drm/i915/gvt: Move mdev attribute groups into kvmgt module
PATCH 1/2 drm/i915/gvt: Move mdev attribute groups into kvmgt module
As kvmgt module contains all handling for VFIO/mdev, leaving mdev attribute groups in gvt module caused dependency issue. Although it was there for possible other hypervisor usage, that turns out never to be true. So this moves all mdev handling into kvmgt module completely to resolve dependency issue.
--- drivers/gpu/drm/i915/gvt/gvt.c | 124 +------------------------ drivers/gpu/drm/i915/gvt/gvt.h | 3 - drivers/gpu/drm/i915/gvt/hypercall.h | 2 +- drivers/gpu/drm/i915/gvt/kvmgt.c | 129 +++++++++++++++++++++++++-- drivers/gpu/drm/i915/gvt/mpt.h | 4 +- 5 files changed, 126 insertions(+), 136 deletions(-)
drivers/gpu/drm/i915/gvt/gvt.c +2 -122
@@ -46,118 +46,6 @@ 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,unsigned int type_group_id) -{ -if (WARN_ON (type_group_id >= gvt->num_types)) -return NULL ; -return &gvt->types[type_group_id]; -} - -static ssize_t available_instances_show (struct mdev_type *mtype, -struct mdev_type_attribute *attr, -char *buf) -{ -struct intel_vgpu_type *type; -unsigned int num =0 ; -void *gvt =kdev_to_i915 (mtype_get_parent_dev (mtype))->gvt; - - type =intel_gvt_find_vgpu_type (gvt,mtype_get_type_group_id (mtype)); -if (!type) - num =0 ; -else - num = type->avail_instance; - -return sprintf (buf,"%u\n" , num); -} - -static ssize_t device_api_show (struct mdev_type *mtype, -struct mdev_type_attribute *attr,char *buf) -{ -return sprintf (buf,"%s\n" ,VFIO_DEVICE_API_PCI_STRING ); -} - -static ssize_t description_show (struct mdev_type *mtype, -struct mdev_type_attribute *attr,char *buf) -{ -struct intel_vgpu_type *type; -void *gvt =kdev_to_i915 (mtype_get_parent_dev (mtype))->gvt; - - type =intel_gvt_find_vgpu_type (gvt,mtype_get_type_group_id (mtype)); -if (!type) -return 0 ; - -return sprintf (buf,"low_gm_size: %dMB\nhigh_gm_size: %dMB\n" -"fence: %d\nresolution: %s\n" -"weight: %d\n" , -BYTES_TO_MB (type->low_gm_size), -BYTES_TO_MB (type->high_gm_size), - type->fence,vgpu_edid_str (type->resolution), - type->weight); -} - -static MDEV_TYPE_ATTR_RO (available_instances); -static MDEV_TYPE_ATTR_RO (device_api); -static MDEV_TYPE_ATTR_RO (description); - -static struct attribute *gvt_type_attrs[] = { - &mdev_type_attr_available_instances.attr, - &mdev_type_attr_device_api.attr, - &mdev_type_attr_description.attr, -NULL , -}; - -static struct attribute_group *gvt_vgpu_type_groups[] = { - [0 ...NR_MAX_INTEL_VGPU_TYPES -1 ] =NULL , -}; - -static bool intel_get_gvt_attrs (struct attribute_group ***intel_vgpu_type_groups) -{ - *intel_vgpu_type_groups = gvt_vgpu_type_groups; -return true; -} - -static int intel_gvt_init_vgpu_type_groups (struct intel_gvt *gvt) -{ -int i, j; -struct intel_vgpu_type *type; -struct attribute_group *group; - -for (i =0 ; i < gvt->num_types; i++) { - type = &gvt->types[i]; - - group =kzalloc (sizeof (struct attribute_group ),GFP_KERNEL ); -if (WARN_ON (!group)) - goto unwind; - - group->name = type->name; - group->attrs = gvt_type_attrs; - gvt_vgpu_type_groups[i] = group; - } - -return 0 ; - -unwind: -for (j =0 ; j < i; j++) { - group = gvt_vgpu_type_groups[j]; -kfree (group); - } - -return -ENOMEM ; -} - -static void intel_gvt_cleanup_vgpu_type_groups (struct intel_gvt *gvt) -{ -int i; -struct attribute_group *group; - -for (i =0 ; i < gvt->num_types; i++) { - group = gvt_vgpu_type_groups[i]; - gvt_vgpu_type_groups[i] =NULL ; -kfree (group); - } -} -static const struct intel_gvt_ops intel_gvt_ops = { .emulate_cfg_read = intel_vgpu_emulate_cfg_read, .emulate_cfg_write = intel_vgpu_emulate_cfg_write,
@@ -169,8 +57,6 @@ static const struct intel_gvt_ops intel_gvt_ops = { .vgpu_reset = intel_gvt_reset_vgpu, .vgpu_activate = intel_gvt_activate_vgpu, .vgpu_deactivate = intel_gvt_deactivate_vgpu, - .gvt_find_vgpu_type = intel_gvt_find_vgpu_type, - .get_gvt_attrs = intel_get_gvt_attrs, .vgpu_query_plane = intel_vgpu_query_plane, .vgpu_get_dmabuf = intel_vgpu_get_dmabuf, .write_protect_handler = intel_vgpu_page_track_handler,
@@ -274,7 +160,6 @@ void intel_gvt_clean_device(struct drm_i915_private *i915)return ;intel_gvt_destroy_idle_vgpu (gvt->idle_vgpu); -intel_gvt_cleanup_vgpu_type_groups (gvt);intel_gvt_clean_vgpu_types (gvt);intel_gvt_debugfs_clean (gvt);
@@ -363,12 +248,6 @@ int intel_gvt_init_device(struct drm_i915_private *i915)if (ret) goto out_clean_thread; - ret =intel_gvt_init_vgpu_type_groups (gvt); -if (ret) { -gvt_err ("failed to init vgpu type groups: %d\n" , ret); - goto out_clean_types; - } - vgpu =intel_gvt_create_idle_vgpu (gvt);if (IS_ERR (vgpu)) { ret =PTR_ERR (vgpu);
@@ -454,7 +333,8 @@ EXPORT_SYMBOL_GPL(intel_gvt_register_hypervisor);void intel_gvt_unregister_hypervisor (void ) { -intel_gvt_hypervisor_host_exit (intel_gvt_host.dev); +void *gvt = (void *)kdev_to_i915 (intel_gvt_host.dev)->gvt; +intel_gvt_hypervisor_host_exit (intel_gvt_host.dev, gvt);module_put (THIS_MODULE ); }EXPORT_SYMBOL_GPL (intel_gvt_unregister_hypervisor);
drivers/gpu/drm/i915/gvt/gvt.h +0 -3
@@ -574,9 +574,6 @@ 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,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 ); int (*write_protect_handler)(struct intel_vgpu *, u64, void *,
drivers/gpu/drm/i915/gvt/hypercall.h +1 -1
@@ -49,7 +49,7 @@ enum hypervisor_type {struct intel_gvt_mpt {enum hypervisor_type type;int (*host_init)(struct device *dev,void *gvt,const void *ops); -void (*host_exit)(struct device *dev); +void (*host_exit)(struct device *dev,void *gvt);int (*attach_vgpu)(void *vgpu,unsigned long *handle);void (*detach_vgpu)(void *vgpu);int (*inject_msi)(unsigned long handle,u32 addr,u16 data);
drivers/gpu/drm/i915/gvt/kvmgt.c +121 -8
154 lines not on this page · raw message
drivers/gpu/drm/i915/gvt/mpt.h +2 -2
@@ -63,13 +63,13 @@ static inline int intel_gvt_hypervisor_host_init(struct device *dev,/** * intel_gvt_hypervisor_host_exit - exit GVT-g host side */ -static inline void intel_gvt_hypervisor_host_exit (struct device *dev) +static inline void intel_gvt_hypervisor_host_exit (struct device *dev,void *gvt) {/* optional to provide */ if (!intel_gvt_host.mpt->host_exit)return ; - intel_gvt_host.mpt->host_exit (dev); + intel_gvt_host.mpt->host_exit (dev, gvt); }/**
Signature · 6 lines
2.31.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 Revert "vfio/gvt: Make DRM_I915_GVT depend on VFIO_MDEV"
This reverts commit 07e543f4f9d116d6b4240644191dee6388ef4a85.
With all mdev handing moved to kvmgt module, only kvmgt should depend on VFIO_MDEV. So revert this one.
--- drivers/gpu/drm/i915/Kconfig | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/drm/i915/Kconfig +0 -1
@@ -102,7 +102,6 @@ config DRM_I915_GVT bool "Enable Intel GVT-g graphics virtualization host support" depends on DRM_I915 depends on 64BIT - depends on VFIO_MDEV default n help Choose this option if you want to enable Intel GVT-g graphics
Signature · 6 lines
2.31.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 2/2] Revert "vfio/gvt: Make DRM_I915_GVT depend on VFIO_MDEV"
Quoted 1 line · On Mon, 26 Apr 2021 17:41:43 +0800 Zhenyu Wang <[email protected]> wrote:
This reverts commit
07e543f4f9d116d6b4240644191dee6388ef4a85.
07e543f4f9d1 ("vfio/gvt: Make DRM_I915_GVT depend on VFIO_MDEV")
Quoted 16 lines
With all mdev handing moved to kvmgt module, only kvmgt should depend on
VFIO_MDEV. So revert this one.Cc Arnd Bergmann <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Alex Williamson <[email protected]>Signed-off-by Zhenyu Wang <[email protected]>--- drivers/gpu/drm/i915/Kconfig | 1 - 1 file changed, 1 deletion(-)drivers/gpu/drm/i915/Kconfig +0
-0
drivers/gpu/drm/i915/Kconfig config DRM_I915_GVT · line 107
Quoted 7 lines
drivers/gpu/drm/i915/Kconfig +0
-1@@ -102,7 +102,6 @@ config DRM_I915_GVT bool "Enable Intel GVT-g graphics virtualization host support" depends on DRM_I915 depends on 64BIT - depends on VFIO_MDEV default n help Choose this option if you want to enable Intel GVT-g graphics
I take it that this retracts your ack from
https://lore.kernel.org/dri-devel/[email protected]/
I'll drop it from consideration for pushing through my tree unless indicated otherwise. Thanks,
Alex
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [Intel-gfx] [PATCH 2/2] Revert "vfio/gvt: Make DRM_I915_GVT depend on VFIO_MDEV"
Quoted 35 lines · Jason Gunthorpe
Quoted 17 lines · Alex Williamson
Quoted 1 line · On Mon, 26 Apr 2021 17:41:43 +0800 Zhenyu Wang <[email protected]> wrote:
This reverts commit
07e543f4f9d116d6b4240644191dee6388ef4a85.
07e543f4f9d1("vfio/gvt: MakeDRM_I915_GVTdepend onVFIO_MDEV")Quoted 10 lines
With all mdev handing moved to kvmgt module, only kvmgt should depend on
VFIO_MDEV. So revert this one.Cc Arnd Bergmann <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Alex Williamson <[email protected]>Signed-off-by Zhenyu Wang <[email protected]>drivers/gpu/drm/i915/Kconfig | 1 - 1 file changed, 1 deletion(-)Quoted 16 lines
drivers/gpu/drm/i915/Kconfig config DRM_I915_GVT · line 107
Quoted 11 lines
drivers/gpu/drm/i915/Kconfig +1
-1+++ b/drivers/gpu/drm/i915/Kconfig@@ -102,7 +102,6 @@ config DRM_I915_GVT bool "Enable Intel GVT-g graphics virtualization host support" depends on DRM_I915 depends on 64BIT - depends on VFIO_MDEV default n help Choose this option if you want to enable Intel GVT-g graphicsI take it that this retracts your ack from
https://lore.kernel.org/dri-devel/[email protected]/
I'll drop it from consideration for pushing through my tree unless indicated otherwise. Thanks,
Quoted 6 lines
In any event you'll need either Arnd's patch or this patch in your tree to avoid randconfig problems.
At this point I would take Arnd's and leave this to go next merge window.
I'm ok with that, so won't block your vfio pull for merge window. I'll send gvt fixes pull in next RC.
Thanks
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 2/2] Revert "vfio/gvt: Make DRM_I915_GVT depend on VFIO_MDEV"
Quoted 39 lines · On Tue, 27 Apr 2021 13:31:39 +0800 Zhenyu Wang <[email protected]> wrote:
Quoted 38 lines · Jason Gunthorpe
Quoted 17 lines · Alex Williamson
Quoted 1 line · On Mon, 26 Apr 2021 17:41:43 +0800 Zhenyu Wang <[email protected]> wrote:
This reverts commit
07e543f4f9d116d6b4240644191dee6388ef4a85.
07e543f4f9d1("vfio/gvt: MakeDRM_I915_GVTdepend onVFIO_MDEV")Quoted 10 lines
With all mdev handing moved to kvmgt module, only kvmgt should depend on
VFIO_MDEV. So revert this one.Cc Arnd Bergmann <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Alex Williamson <[email protected]>Signed-off-by Zhenyu Wang <[email protected]>drivers/gpu/drm/i915/Kconfig | 1 - 1 file changed, 1 deletion(-)Quoted 16 lines
drivers/gpu/drm/i915/Kconfig config DRM_I915_GVT · line 107
Quoted 11 lines
drivers/gpu/drm/i915/Kconfig +1
-1+++ b/drivers/gpu/drm/i915/Kconfig@@ -102,7 +102,6 @@ config DRM_I915_GVT bool "Enable Intel GVT-g graphics virtualization host support" depends on DRM_I915 depends on 64BIT - depends on VFIO_MDEV default n help Choose this option if you want to enable Intel GVT-g graphicsI take it that this retracts your ack from
https://lore.kernel.org/dri-devel/[email protected]/
I'll drop it from consideration for pushing through my tree unless indicated otherwise. Thanks,In any event you'll need either Arnd's patch or this patch in your tree to avoid randconfig problems.
Quoted 6 lines
Quoted 3 lines
At this point I would take Arnd's and leave this to go next merge window.
I'm ok with that, so won't block your vfio pull for merge window. I'll send gvt fixes pull in next RC.
Ok, I've pushed Arnd's fix to my next branch, I'll get it in for rc1. Thanks,
Alex
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BUILD: failure for series starting with [1/2] drm/i915/gvt: Move mdev attribute groups into kvmgt module
In reply to Zhenyu Wang== Series Details ==
== Series Details ==
Series: series starting with [1/2] drm/i915/gvt: Move mdev attribute groups into kvmgt module
URL : https://patchwork.freedesktop.org/series/89478/
State : failure
== Summary ==
Applying: drm/i915/gvt: Move mdev attribute groups into kvmgt module
error: sha1 information is lacking or useless (drivers/gpu/drm/i915/gvt/gvt.c).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 drm/i915/gvt: Move mdev attribute groups into kvmgt module When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 22 lines · Jason Gunthorpe
Quoted 6 lines · Zhenyu Wang
drivers/gpu/drm/i915/gvt/kvmgt.c +1
-1@@ -1667,19 +1773,26 @@ static struct mdev_parent_ops intel_vgpu_ops = {static int kvmgt_host_init (struct device *dev,void *gvt,const void *ops) { -struct attribute_group **kvm_vgpu_type_groups; +int ret;drivers/gpu/drm/i915/gvt/kvmgt.c static struct mdev_parent_ops intel_vgpu_ops = { · line 1783
Quoted 10 lines
drivers/gpu/drm/i915/gvt/kvmgt.c +5
-3+ + ret =intel_gvt_init_vgpu_type_groups ((struct intel_gvt *)gvt); +if (ret) +return ret; intel_gvt_ops = ops; -if (!intel_gvt_ops->get_gvt_attrs (&kvm_vgpu_type_groups)) -return -EFAULT ; - intel_vgpu_ops.supported_type_groups = kvm_vgpu_type_groups; + intel_vgpu_ops.supported_type_groups = gvt_vgpu_type_groups;This patch is an improvement, but this fictional dynamic behavior is still wrong. The
supported_type_groupsdirectly flows from thevgpu_typesarray invgpu.cand it should not be split up like this
Quoted 3 lines
The code copies the rodata
vgpu_typesinto dynamic memorygvt->typesthen copies that dynamic memory into a dynamicgvt_vgpu_type_groups, which makes very little sense at all.
vgpu_types is static for we want fixed vgpu mdev type, but actual supported types depend on HW resources e.g aperture mem, fence, etc, that's dynamic for gvt->types, so gvt_vgpu_type_groups is dynamic from gvt->types.
Quoted 5 lines
vgpu_typesshould be moved to kvmgt and everything should be static, like every other mdev driver. Copy the 'type' information from thegpu_typesstatic when the mdev is created.
I don't think that's necessary, as it's not static for gvt at all. The logic to handle type resource change can still be in vgpu.c
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 28 lines · Jason Gunthorpe
Quoted 27 lines · Zhenyu Wang
Quoted 25 lines · Jason Gunthorpe
Quoted 6 lines · Zhenyu Wang
drivers/gpu/drm/i915/gvt/kvmgt.c +1
-1@@ -1667,19 +1773,26 @@ static struct mdev_parent_ops intel_vgpu_ops = {static int kvmgt_host_init (struct device *dev,void *gvt,const void *ops) { -struct attribute_group **kvm_vgpu_type_groups; +int ret;drivers/gpu/drm/i915/gvt/kvmgt.c static struct mdev_parent_ops intel_vgpu_ops = { · line 1783
Quoted 10 lines
drivers/gpu/drm/i915/gvt/kvmgt.c +5
-3+ + ret =intel_gvt_init_vgpu_type_groups ((struct intel_gvt *)gvt); +if (ret) +return ret; intel_gvt_ops = ops; -if (!intel_gvt_ops->get_gvt_attrs (&kvm_vgpu_type_groups)) -return -EFAULT ; - intel_vgpu_ops.supported_type_groups = kvm_vgpu_type_groups; + intel_vgpu_ops.supported_type_groups = gvt_vgpu_type_groups;This patch is an improvement, but this fictional dynamic behavior is still wrong. The
supported_type_groupsdirectly flows from thevgpu_typesarray invgpu.cand it should not be split up like thisThe code copies the rodata
vgpu_typesinto dynamic memorygvt->typesthen copies that dynamic memory into a dynamicgvt_vgpu_type_groups, which makes very little sense at all.
Quoted 7 lines
Quoted 3 lines
vgpu_typesis static for we want fixed vgpu mdev type, but actual supported types depend on HW resources e.g aperture mem, fence, etc, that's dynamic forgvt->types, sogvt_vgpu_type_groupsis dynamic fromgvt->types.Well, that's worse then, intel_vgpu_ops.supported_type_groups is a static global, it cannot depend on HW variable calculations.
sorry, maybe I didn't describe this properly, gvt_vgpu_type_groups is static global, but the actual supported types is determined from gvt->types and initialized before mdev device register.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 41 lines · Jason Gunthorpe
Quoted 33 lines · Zhenyu Wang
Quoted 32 lines · Jason Gunthorpe
Quoted 30 lines · Zhenyu Wang
Quoted 22 lines · Jason Gunthorpe
Quoted 6 lines · Zhenyu Wang
drivers/gpu/drm/i915/gvt/kvmgt.c +1
-1@@ -1667,19 +1773,26 @@ static struct mdev_parent_ops intel_vgpu_ops = {static int kvmgt_host_init (struct device *dev,void *gvt,const void *ops) { -struct attribute_group **kvm_vgpu_type_groups; +int ret;drivers/gpu/drm/i915/gvt/kvmgt.c static struct mdev_parent_ops intel_vgpu_ops = { · line 1783
Quoted 10 lines
drivers/gpu/drm/i915/gvt/kvmgt.c +5
-3+ + ret =intel_gvt_init_vgpu_type_groups ((struct intel_gvt *)gvt); +if (ret) +return ret; intel_gvt_ops = ops; -if (!intel_gvt_ops->get_gvt_attrs (&kvm_vgpu_type_groups)) -return -EFAULT ; - intel_vgpu_ops.supported_type_groups = kvm_vgpu_type_groups; + intel_vgpu_ops.supported_type_groups = gvt_vgpu_type_groups;This patch is an improvement, but this fictional dynamic behavior is still wrong. The
supported_type_groupsdirectly flows from thevgpu_typesarray invgpu.cand it should not be split up like thisQuoted 3 lines
The code copies the rodata
vgpu_typesinto dynamic memorygvt->typesthen copies that dynamic memory into a dynamicgvt_vgpu_type_groups, which makes very little sense at all.
vgpu_typesis static for we want fixed vgpu mdev type, but actual supported types depend on HW resources e.g aperture mem, fence, etc, that's dynamic forgvt->types, sogvt_vgpu_type_groupsis dynamic fromgvt->types.Quoted 6 lines
Quoted 2 lines
Well, that's worse then, intel_vgpu_ops.supported_type_groups is a static global, it cannot depend on HW variable calculations.
sorry, maybe I didn't describe this properly,
gvt_vgpu_type_groupsis static global, but the actual supported types is determined fromgvt->typesand initialized before mdev device register.
Quoted 6 lines
No, I got it, I saw the code too.
Think about what happens if there are two GPUs in the system, you get two gvt's and with different properties and you are trying to squeeze that into a single static global - it doesn't work.
Well, that's not what this change trys to resolve and on gvt supported platform that's not an available hardware configuration for IGD. So I think this is fine.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx