Re: [Intel-gfx] [PATCH v7 05/11] drm/i915: gvt: Introduce the basic architecture of GVT-g
On ti, 2016-06-07 at 11:18 -0400, Zhi Wang wrote: > This patch introduces the very basic framework of GVT-g device model, > includes basic prototypes, definitions, initialization. > > v7: > - Refine the URL link in Kconfig. (Joonas) > - Refine the introduction of GVT-g host support in Kconfig. (Joonas) > - Remove the macro GVT_ALIGN(), use round_down() instead. (Joonas) > - Make "struct intel_gvt" a data member in struct drm_i915_private.(Joonas) > - Remove {alloc, free}_gvt_device() > - Rename intel_gvt_{create, destroy}_gvt_device() > - Expost intel_gvt_init_host() > - Remove the dummy "struct intel_gvt" declaration in intel_gvt.h (Joonas) > > v6: > - Refine introduction in Kconfig. (Chris) > - The exposed API functions will take struct intel_gvt * instead of > void *. (Chris/Tvrtko) > - Remove most memebers of strct intel_gvt_device_info. Will add them > in the device model patches.(Chris) > - Remove gvt_info() and gvt_err() in debug.h. (Chris) > - Move GVT kernel parameter into i915_params. (Chris) > - Remove include/drm/i915_gvt.h, as GVT-g will be built within i915. > - Remove the redundant struct i915_gvt *, as the functions in i915 > will directly take struct intel_gvt *. > - Add more comments for reviewer. > > v5: > Take Tvrtko's comments: > - Fix the misspelled words in Kconfig > - Let functions take drm_i915_private * instead of struct drm_device * > - Remove redundant prints/local varible initialization > > v3: > Take Joonas' comments: > - Change file name i915_gvt.* to intel_gvt.* > - Move GVT kernel parameter into intel_gvt.c > - Remove redundant debug macros > - Change error handling style > - Add introductions for some stub functions > - Introduce drm/i915_gvt.h. > > Take Kevin's comments: > - Move GVT-g host/guest check into intel_vgt_balloon in i915_gem_gtt.c > > v2: > - Introduce i915_gvt.c. > It's necessary to introduce the stubs between i915 driver and GVT-g host, > as GVT-g components is configurable in kernel config. When disabled, the > stubs here do nothing. > > Take Joonas' comments: > - Replace boolean return value with int. > - Replace customized info/warn/debug macros with DRM macros. > - Document all non-static functions like i915. > - Remove empty and unused functions. > - Replace magic number with marcos. > - Set GVT-g in kernel config to "n" by default. > > Signed-off-by: Zhi WangAgain, add Cc: everyone who has given comments. > --- > drivers/gpu/drm/i915/Kconfig | 22 + > drivers/gpu/drm/i915/Makefile| 5 ++ > drivers/gpu/drm/i915/gvt/Makefile| 5 ++ > drivers/gpu/drm/i915/gvt/debug.h | 34 > drivers/gpu/drm/i915/gvt/gvt.c | 158 > +++ > drivers/gpu/drm/i915/gvt/gvt.h | 72 > drivers/gpu/drm/i915/gvt/hypercall.h | 38 + > drivers/gpu/drm/i915/gvt/mpt.h | 49 +++ > drivers/gpu/drm/i915/i915_dma.c | 16 +++- > drivers/gpu/drm/i915/i915_drv.h | 10 +++ > drivers/gpu/drm/i915/i915_params.c | 5 ++ > drivers/gpu/drm/i915/i915_params.h | 1 + > drivers/gpu/drm/i915/intel_gvt.c | 100 ++ > drivers/gpu/drm/i915/intel_gvt.h | 45 ++ > 14 files changed, 556 insertions(+), 4 deletions(-) > create mode 100644 drivers/gpu/drm/i915/gvt/Makefile > create mode 100644 drivers/gpu/drm/i915/gvt/debug.h > create mode 100644 drivers/gpu/drm/i915/gvt/gvt.c > create mode 100644 drivers/gpu/drm/i915/gvt/gvt.h > create mode 100644 drivers/gpu/drm/i915/gvt/hypercall.h > create mode 100644 drivers/gpu/drm/i915/gvt/mpt.h > create mode 100644 drivers/gpu/drm/i915/intel_gvt.c > create mode 100644 drivers/gpu/drm/i915/intel_gvt.h > > +/** > + * intel_gvt_clean_device - clean a GVT device > + * @gvt: intel gvt device > + * > + * This function is called at the driver unloading stage, to free the > + * resources owned by a GVT device. > + * > + */ > +void intel_gvt_clean_device(struct drm_i915_private *dev_priv) > +{ > + struct intel_gvt *gvt = _priv->gvt; > + > + if (WARN_ON(!gvt->initialized)) > + return; > + > + mutex_lock(_gvt_host.gvt_idr_lock); Why is this lock necessary? I assume intel_gvt_init will be called on driver load (same for fini part), and there should be no races. With that explained or removed; Reviewed-by: Joonas Lahtinen > + idr_remove(_gvt_host.gvt_idr, gvt->id); > + mutex_unlock(_gvt_host.gvt_idr_lock); > + /* Other de-initialization of GVT components will be introduced. */ > + > + gvt->initialized = false; > +} > + -- Joonas Lahtinen Open Source Technology Center Intel Corporation ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH v7 05/11] drm/i915: gvt: Introduce the basic architecture of GVT-g
This patch introduces the very basic framework of GVT-g device model, includes basic prototypes, definitions, initialization. v7: - Refine the URL link in Kconfig. (Joonas) - Refine the introduction of GVT-g host support in Kconfig. (Joonas) - Remove the macro GVT_ALIGN(), use round_down() instead. (Joonas) - Make "struct intel_gvt" a data member in struct drm_i915_private.(Joonas) - Remove {alloc, free}_gvt_device() - Rename intel_gvt_{create, destroy}_gvt_device() - Expost intel_gvt_init_host() - Remove the dummy "struct intel_gvt" declaration in intel_gvt.h (Joonas) v6: - Refine introduction in Kconfig. (Chris) - The exposed API functions will take struct intel_gvt * instead of void *. (Chris/Tvrtko) - Remove most memebers of strct intel_gvt_device_info. Will add them in the device model patches.(Chris) - Remove gvt_info() and gvt_err() in debug.h. (Chris) - Move GVT kernel parameter into i915_params. (Chris) - Remove include/drm/i915_gvt.h, as GVT-g will be built within i915. - Remove the redundant struct i915_gvt *, as the functions in i915 will directly take struct intel_gvt *. - Add more comments for reviewer. v5: Take Tvrtko's comments: - Fix the misspelled words in Kconfig - Let functions take drm_i915_private * instead of struct drm_device * - Remove redundant prints/local varible initialization v3: Take Joonas' comments: - Change file name i915_gvt.* to intel_gvt.* - Move GVT kernel parameter into intel_gvt.c - Remove redundant debug macros - Change error handling style - Add introductions for some stub functions - Introduce drm/i915_gvt.h. Take Kevin's comments: - Move GVT-g host/guest check into intel_vgt_balloon in i915_gem_gtt.c v2: - Introduce i915_gvt.c. It's necessary to introduce the stubs between i915 driver and GVT-g host, as GVT-g components is configurable in kernel config. When disabled, the stubs here do nothing. Take Joonas' comments: - Replace boolean return value with int. - Replace customized info/warn/debug macros with DRM macros. - Document all non-static functions like i915. - Remove empty and unused functions. - Replace magic number with marcos. - Set GVT-g in kernel config to "n" by default. Signed-off-by: Zhi Wang--- drivers/gpu/drm/i915/Kconfig | 22 + drivers/gpu/drm/i915/Makefile| 5 ++ drivers/gpu/drm/i915/gvt/Makefile| 5 ++ drivers/gpu/drm/i915/gvt/debug.h | 34 drivers/gpu/drm/i915/gvt/gvt.c | 158 +++ drivers/gpu/drm/i915/gvt/gvt.h | 72 drivers/gpu/drm/i915/gvt/hypercall.h | 38 + drivers/gpu/drm/i915/gvt/mpt.h | 49 +++ drivers/gpu/drm/i915/i915_dma.c | 16 +++- drivers/gpu/drm/i915/i915_drv.h | 10 +++ drivers/gpu/drm/i915/i915_params.c | 5 ++ drivers/gpu/drm/i915/i915_params.h | 1 + drivers/gpu/drm/i915/intel_gvt.c | 100 ++ drivers/gpu/drm/i915/intel_gvt.h | 45 ++ 14 files changed, 556 insertions(+), 4 deletions(-) create mode 100644 drivers/gpu/drm/i915/gvt/Makefile create mode 100644 drivers/gpu/drm/i915/gvt/debug.h create mode 100644 drivers/gpu/drm/i915/gvt/gvt.c create mode 100644 drivers/gpu/drm/i915/gvt/gvt.h create mode 100644 drivers/gpu/drm/i915/gvt/hypercall.h create mode 100644 drivers/gpu/drm/i915/gvt/mpt.h create mode 100644 drivers/gpu/drm/i915/intel_gvt.c create mode 100644 drivers/gpu/drm/i915/intel_gvt.h diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig index 29a32b1..7769e46 100644 --- a/drivers/gpu/drm/i915/Kconfig +++ b/drivers/gpu/drm/i915/Kconfig @@ -57,6 +57,28 @@ config DRM_I915_USERPTR If in doubt, say "Y". +config DRM_I915_GVT +bool "Enable Intel GVT-g graphics virtualization host support" +depends on DRM_I915 +default n +help + Choose this option if you want to enable Intel GVT-g graphics + virtualization technology host support with integrated graphics. + With GVT-g, it's possible to have one integrated graphics + device shared by multiple VMs under different hypervisors. + + Note that at least one hypervisor like Xen or KVM is required for + this driver to work, and it only supports newer device from + Broadwell+. For further information and setup guide, you can + visit: http://01.org/igvt-g. + + Now it's just a stub to support the modifications of i915 for + GVT device model. It requires at least one MPT modules for Xen/KVM + and other components of GVT device model to work. Use it under + you own risk. + + If in doubt, say "N". + menu "drm/i915 Debugging" depends on DRM_I915 depends on EXPERT diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 7e29444..276abf1 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -104,6 +104,11 @@ i915-y +=