Change KVMGT into self loadable module
v6 cover Change KVMGT into self loadable module
This series try to change 'kvmgt' as self loadable module to enable GVT feature for VFIO/mdev interface when user loads 'kvmgt' module, instead of current method to load hypervisor module when i915/gvt device model initializes.
Resend whole series for QA's jekins job.
v6:
- remove unused variable
Zhenyu Wang (3):
drm/i915/gvt: mandatory require hypervisor's host_init drm/i915/gvt: remove unused parameter for hypervisor's host_exit call drm/i915/gvt: Change KVMGT as self load module
drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/gvt/Makefile | 1 - drivers/gpu/drm/i915/gvt/gvt.c | 108 +++++++++++---------------- drivers/gpu/drm/i915/gvt/gvt.h | 6 +- drivers/gpu/drm/i915/gvt/hypercall.h | 9 ++- drivers/gpu/drm/i915/gvt/kvmgt.c | 18 ++++- drivers/gpu/drm/i915/gvt/mpt.h | 13 ++-- drivers/gpu/drm/i915/intel_gvt.c | 9 --- 8 files changed, 75 insertions(+), 90 deletions(-)
Signature · 6 lines
2.19.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v6 1/3 drm/i915/gvt: mandatory require hypervisor's host_init
Don't mark hypervisor module's host_init as optional, but mandatory required.
--- drivers/gpu/drm/i915/gvt/mpt.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gvt/mpt.h +2 -3
@@ -50,11 +50,10 @@* Zero on success, negative error code if failed */ static inline int intel_gvt_hypervisor_host_init (struct device *dev, -void *gvt,const void *ops) +void *gvt,const void *ops) { -/* optional to provide */ if (!intel_gvt_host.mpt->host_init) -return 0 ; +return -ENODEV ;return intel_gvt_host.mpt->host_init (dev, gvt, ops); }
Signature · 6 lines
2.19.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v6 2/3 drm/i915/gvt: remove unused parameter for hypervisor's host_exit call
In reply to Zhenyu WangThe parameter 'void *gvt' is not used and required for hypervisor's exit call. Even for non-merged Xen hypervisor support. So just remove it.
--- drivers/gpu/drm/i915/gvt/gvt.c | 2 +- drivers/gpu/drm/i915/gvt/hypercall.h | 2 +- drivers/gpu/drm/i915/gvt/kvmgt.c | 2 +- drivers/gpu/drm/i915/gvt/mpt.h | 5 ++--- 4 files changed, 5 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/gvt/gvt.c +1 -1
@@ -316,7 +316,7 @@ void intel_gvt_clean_device(struct drm_i915_private *dev_priv)return ;intel_gvt_destroy_idle_vgpu (gvt->idle_vgpu); -intel_gvt_hypervisor_host_exit (&dev_priv->drm.pdev->dev, gvt); +intel_gvt_hypervisor_host_exit (&dev_priv->drm.pdev->dev);intel_gvt_cleanup_vgpu_type_groups (gvt);intel_gvt_clean_vgpu_types (gvt);
drivers/gpu/drm/i915/gvt/hypercall.h +1 -1
@@ -39,7 +39,7 @@*/ struct intel_gvt_mpt {int (*host_init)(struct device *dev,void *gvt,const void *ops); -void (*host_exit)(struct device *dev,void *gvt); +void (*host_exit)(struct device *dev);int (*attach_vgpu)(void *vgpu,unsigned long *handle);void (*detach_vgpu)(unsigned long handle);int (*inject_msi)(unsigned long handle,u32 addr,u16 data);
drivers/gpu/drm/i915/gvt/kvmgt.c +1 -1
@@ -1467,7 +1467,7 @@ static int kvmgt_host_init(struct device *dev, void *gvt, const void *ops)return mdev_register_device (dev, &intel_vgpu_ops); } -static void kvmgt_host_exit (struct device *dev,void *gvt) +static void kvmgt_host_exit (struct device *dev) {mdev_unregister_device (dev); }
drivers/gpu/drm/i915/gvt/mpt.h +2 -3
@@ -61,14 +61,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, -void *gvt) +static inline void intel_gvt_hypervisor_host_exit (struct device *dev) {/* optional to provide */ if (!intel_gvt_host.mpt->host_exit)return ; - intel_gvt_host.mpt->host_exit (dev, gvt); + intel_gvt_host.mpt->host_exit (dev); }/**
Signature · 6 lines
2.19.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v6 3/3 drm/i915/gvt: Change KVMGT as self load module
In reply to Zhenyu WangThis trys to make 'kvmgt' module as self loadable instead of loading by i915/gvt device model. So hypervisor specific module could be stand-alone, e.g only after loading hypervisor specific module, GVT feature could be enabled via specific hypervisor interface, e.g VFIO/mdev.
So this trys to use hypervisor module register/unregister interface for that. Hypervisor module needs to take care of module reference itself when working for hypervisor interface, e.g for VFIO/mdev, hypervisor module would reference counting mdev when open and release.
This makes 'kvmgt' module really split from GVT device model. User needs to load 'kvmgt' to enable VFIO/mdev interface.
v6:
- remove unused variable
v5:
- put module reference in register error path
v4:
- fix checkpatch warning
v3:
- Fix module reference handling for device open and release. Unused mdev devices would be cleaned up in device unregister when module unload.
v2:
- Fix kvmgt order after i915 for built-in case
--- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/gvt/Makefile | 1 - drivers/gpu/drm/i915/gvt/gvt.c | 108 +++++++++++---------------- drivers/gpu/drm/i915/gvt/gvt.h | 6 +- drivers/gpu/drm/i915/gvt/hypercall.h | 7 +- drivers/gpu/drm/i915/gvt/kvmgt.c | 16 +++- drivers/gpu/drm/i915/gvt/mpt.h | 3 + drivers/gpu/drm/i915/intel_gvt.c | 9 --- 8 files changed, 69 insertions(+), 82 deletions(-)
drivers/gpu/drm/i915/Makefile +1 -0
@@ -195,3 +195,4 @@ endif i915-y += intel_lpe_audio.o obj-$(CONFIG_DRM_I915) += i915.o +obj-$(CONFIG_DRM_I915_GVT_KVMGT) += gvt/kvmgt.o
drivers/gpu/drm/i915/gvt/Makefile +0 -1
@@ -7,4 +7,3 @@ GVT_SOURCE := gvt.o aperture_gm.o handlers.o vgpu.o trace_points.o firmware.o \ ccflags-y += -I$(src) -I$(src)/$(GVT_DIR) i915-y += $(addprefix $(GVT_DIR)/, $(GVT_SOURCE)) -obj-$(CONFIG_DRM_I915_GVT_KVMGT) += $(GVT_DIR)/kvmgt.o
drivers/gpu/drm/i915/gvt/gvt.c +44 -64
141 lines not on this page · raw message
drivers/gpu/drm/i915/gvt/gvt.h +1 -5
@@ -52,12 +52,8 @@#define GVT_MAX_VGPU 8 -enum { -INTEL_GVT_HYPERVISOR_XEN =0 , -INTEL_GVT_HYPERVISOR_KVM , -}; -struct intel_gvt_host { +struct device *dev;bool initialized;int hypervisor_type;struct intel_gvt_mpt *mpt;
drivers/gpu/drm/i915/gvt/hypercall.h +6 -1
@@ -33,11 +33,17 @@ #ifndef _GVT_HYPERCALL_H_ #define _GVT_HYPERCALL_H_ +enum hypervisor_type { + INTEL_GVT_HYPERVISOR_XEN = 0, + INTEL_GVT_HYPERVISOR_KVM, +}; + /* * Specific GVT-g MPT modules function collections. Currently GVT-g supports * both Xen and KVM by providing dedicated hypervisor-related MPT modules. */ 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); int (*attach_vgpu)(void *vgpu, unsigned long *handle);
@@ -67,6 +73,5 @@ struct intel_gvt_mpt { };extern struct intel_gvt_mpt xengt_mpt; -extern struct intel_gvt_mpt kvmgt_mpt;#endif /* _GVT_HYPERCALL_H_ */
drivers/gpu/drm/i915/gvt/kvmgt.c +14 -2
@@ -627,6 +627,12 @@ static int intel_vgpu_open(struct mdev_device *mdev) goto undo_iommu; } +/* Take a module reference as mdev core doesn't take +* a reference for vendor driver. +*/ +if (!try_module_get (THIS_MODULE )) + goto undo_group; + ret =kvmgt_guest_init (mdev);if (ret) goto undo_group;
@@ -679,6 +685,9 @@ static void __intel_vgpu_release(struct intel_vgpu *vgpu) &vgpu->vdev.group_notifier);WARN (ret,"vfio_unregister_notifier for group failed: %d\n" , ret); +/* dereference module reference taken at open */ +module_put (THIS_MODULE ); + info = (struct kvmgt_guest_info *)vgpu->handle;kvmgt_guest_exit (info);
@@ -1849,7 +1858,8 @@ static bool kvmgt_is_valid_gfn(unsigned long handle, unsigned long gfn)return ret; } -struct intel_gvt_mpt kvmgt_mpt = { +static struct intel_gvt_mpt kvmgt_mpt = { + .type =INTEL_GVT_HYPERVISOR_KVM , .host_init = kvmgt_host_init, .host_exit = kvmgt_host_exit, .attach_vgpu = kvmgt_attach_vgpu,
@@ -1868,15 +1878,17 @@ struct intel_gvt_mpt kvmgt_mpt = { .put_vfio_device = kvmgt_put_vfio_device, .is_valid_gfn = kvmgt_is_valid_gfn, }; -EXPORT_SYMBOL_GPL (kvmgt_mpt);static int __init kvmgt_init (void ) { +if (intel_gvt_register_hypervisor (&kvmgt_mpt) <0 ) +return -ENODEV ;return 0 ; } static void __exit kvmgt_exit(void) { +intel_gvt_unregister_hypervisor (); }module_init (kvmgt_init);
drivers/gpu/drm/i915/gvt/mpt.h +3 -0
@@ -360,4 +360,7 @@ static inline bool intel_gvt_hypervisor_is_valid_gfn( return intel_gvt_host.mpt->is_valid_gfn(vgpu->handle, gfn); } +int intel_gvt_register_hypervisor (struct intel_gvt_mpt *); +void intel_gvt_unregister_hypervisor (void ); +#endif /* _GVT_MPT_H_ */
drivers/gpu/drm/i915/intel_gvt.c +0 -9
@@ -105,15 +105,6 @@ int intel_gvt_init(struct drm_i915_private *dev_priv)return -EIO ; } -/* -* We're not in host or fail to find a MPT module, disable GVT-g -*/ - ret =intel_gvt_init_host (); -if (ret) { -DRM_DEBUG_DRIVER ("Not in host or MPT modules not found\n" ); - goto bail; - } - ret =intel_gvt_init_device (dev_priv);if (ret) {DRM_DEBUG_DRIVER ("Fail to init GVT device\n" );
Signature · 6 lines
2.19.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v6 3/3] drm/i915/gvt: Change KVMGT as self load module
Quoting Zhenyu Wang (2018-12-07 10:16:53)
Quoted 26 lines
This trys to make 'kvmgt' module as self loadable instead of loading by i915/gvt device model. So hypervisor specific module could be stand-alone, e.g only after loading hypervisor specific module, GVT feature could be enabled via specific hypervisor interface, e.g VFIO/mdev.
So this trys to use hypervisor module register/unregister interface for that. Hypervisor module needs to take care of module reference itself when working for hypervisor interface, e.g for VFIO/mdev, hypervisor module would reference counting mdev when open and release.
This makes 'kvmgt' module really split from GVT device model. User needs to load 'kvmgt' to enable VFIO/mdev interface.
v6:
- remove unused variablev5:
- put module reference in register error pathv4:
- fix checkpatch warningv3:
- Fix module reference handling for device open and release. Unused mdev devices would be cleaned up in device unregister when module unload.
Quoted 8 lines
v2:
- Fix kvmgt order after i915 for built-in caseCc "Yuan, Hang" <[email protected]>Cc Alex Williamson <[email protected]>Cc "He, Min" <[email protected]>Reviewed-by Yuan, Hang <[email protected]>Signed-off-by Zhenyu Wang <[email protected]>
For what i915 is concerned, this is the desireable direction. When combined with the other series about making GVT build independantly, and golden MMIO state (instead of capturing at boot).
With those This should both expedite the i915 driver loading on DOM0, when GVT can be loaded as secondary module. And the golden MMIO state instead of capturing from host would avoid leaking any changes in host configuration (say, due to BIOS update) to the guests.
So as an intermediary step to that direction, for i915 portion (not that much in this case) this is:
I'm expecting somebody with more inisght to review the code under gvt/.
Regards, Joonas
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for Change KVMGT into self loadable module (rev4)
In reply to Zhenyu Wang== Series Details ==
== Series Details ==
Series: Change KVMGT into self loadable module (rev4)
URL : https://patchwork.freedesktop.org/series/53379/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_5280 -> Patchwork_11043
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/53379/revisions/4/mbox/
Known issues
------------
Here are the changes found in Patchwork_11043 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_ctx_create@basic-files:
- fi-bsw-kefka: PASS -> FAIL [fdo#108656]
* igt@gem_exec_suspend@basic-s3:
- fi-blb-e6850: PASS -> INCOMPLETE [fdo#107718]
[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#108656]: https://bugs.freedesktop.org/show_bug.cgi?id=108656
Participating hosts (45 -> 42)
------------------------------
Additional (2): fi-skl-guc fi-skl-6600u
Missing (5): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-icl-y
Build changes
-------------
* Linux: CI_DRM_5280 -> Patchwork_11043
CI_DRM_5280: 6047933c2fafdfd42353d735b213e74826d5a939 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4743: edb2db2cf2b6665d7ba3fa9117263302f6307a4f @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_11043: 4517d0efeed2dfbf726017b688f12a5ba479e6ec @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
4517d0efeed2 drm/i915/gvt: Change KVMGT as self load module c9a054b04171 drm/i915/gvt: remove unused parameter for hypervisor's host_exit call ebe9b6bbbd81 drm/i915/gvt: mandatory require hypervisor's host_init
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_11043/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for Change KVMGT into self loadable module (rev4)
In reply to Zhenyu Wang== Series Details ==
== Series Details ==
Series: Change KVMGT into self loadable module (rev4)
URL : https://patchwork.freedesktop.org/series/53379/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_5280_full -> Patchwork_11043_full
====================================================
Summary
-------
**SUCCESS**
No regressions found.
Known issues
------------
Here are the changes found in Patchwork_11043_full that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_exec_schedule@pi-ringfull-render:
- shard-glk: NOTRUN -> FAIL [fdo#103158]
* {igt@kms_plane@pixel-format-pipe-b-planes-source-clamping}:
- shard-glk: PASS -> FAIL [fdo#108948]
* igt@kms_plane@plane-position-covered-pipe-c-planes:
- shard-glk: PASS -> FAIL [fdo#103166]
* igt@kms_plane_multiple@atomic-pipe-a-tiling-y:
- shard-apl: PASS -> FAIL [fdo#103166]
* {igt@kms_rotation_crc@multiplane-rotation-cropping-top}:
- shard-kbl: PASS -> DMESG-WARN [fdo#105604]
- shard-glk: PASS -> DMESG-WARN [fdo#105763] / [fdo#106538]
* igt@kms_setmode@basic:
- shard-apl: PASS -> FAIL [fdo#99912]
#### Possible fixes ####
* igt@kms_busy@basic-modeset-a:
- shard-apl: DMESG-WARN [fdo#103558] / [fdo#105602] -> PASS +9
* igt@kms_busy@extended-modeset-hang-newfb-render-b:
- shard-kbl: DMESG-WARN [fdo#107956] -> PASS
* igt@kms_cursor_crc@cursor-128x128-sliding:
- shard-apl: FAIL [fdo#103232] -> PASS +2
* igt@kms_cursor_crc@cursor-256x256-dpms:
- shard-glk: FAIL [fdo#103232] -> PASS
* igt@kms_cursor_crc@cursor-64x64-suspend:
- shard-apl: FAIL [fdo#103191] / [fdo#103232] -> PASS
* igt@kms_flip@2x-flip-vs-expired-vblank-interruptible:
- shard-glk: FAIL [fdo#105363] -> PASS
* igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-indfb-draw-mmap-cpu:
- shard-glk: FAIL [fdo#103167] -> PASS +1
* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-render:
- shard-apl: FAIL [fdo#103167] -> PASS
* igt@kms_plane@pixel-format-pipe-c-planes:
- shard-glk: FAIL [fdo#103166] -> PASS +1
* igt@kms_plane_multiple@atomic-pipe-a-tiling-yf:
- shard-apl: FAIL [fdo#103166] -> PASS
#### Warnings ####
* igt@kms_content_protection@legacy:
- shard-apl: FAIL [fdo#108597] -> INCOMPLETE [fdo#103927]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#103158]: https://bugs.freedesktop.org/show_bug.cgi?id=103158
[fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
[fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
[fdo#103558]: https://bugs.freedesktop.org/show_bug.cgi?id=103558
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
[fdo#105602]: https://bugs.freedesktop.org/show_bug.cgi?id=105602
[fdo#105604]: https://bugs.freedesktop.org/show_bug.cgi?id=105604
[fdo#105763]: https://bugs.freedesktop.org/show_bug.cgi?id=105763
[fdo#106538]: https://bugs.freedesktop.org/show_bug.cgi?id=106538
[fdo#107956]: https://bugs.freedesktop.org/show_bug.cgi?id=107956
[fdo#108597]: https://bugs.freedesktop.org/show_bug.cgi?id=108597
[fdo#108948]: https://bugs.freedesktop.org/show_bug.cgi?id=108948
[fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912
Participating hosts (7 -> 5)
------------------------------
Missing (2): shard-skl shard-iclb
Build changes
-------------
* Linux: CI_DRM_5280 -> Patchwork_11043
CI_DRM_5280: 6047933c2fafdfd42353d735b213e74826d5a939 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4743: edb2db2cf2b6665d7ba3fa9117263302f6307a4f @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_11043: 4517d0efeed2dfbf726017b688f12a5ba479e6ec @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_11043/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx