Introduce GVT context support
v3 cover Introduce GVT context support
This patchset is used to discuss and finalize the i915 changes required by GVT context.
Thanks Joonas/Daniel/Kevin for the comments.
v3:
- Address comments from Joonas/Kevin.
- Add more introductions for better review.
- Factor out and expose some functions in i915_gem_fence.c for fence stealing
This previous review email:
[RFCv2 02/14] drm/i915/gvt: Introduce the basic architecture of GVT-g
http://www.spinics.net/lists/intel-gfx/msg88547.html
[RFCv2 03/14] drm/i915: Introduce host graphics memory/fence partition for GVT-g
http://www.spinics.net/lists/intel-gfx/msg88359.html
Acknowledgment
---------------
iGVT-g implementation is several years effort and many people contributed to the code. There names are not here yet. In later formal patchset we will reflect individual's contribution.
Meanwhile, in the previous iGVT-g related discussion, Daniel, Chris and Joonas ever gave very good inputs. We appreciate them and look forward to more comments/suggestions from community.
We are trying to get more familiar with i915 and willing to adopt suggestions to keep improving. We hope to work with community together to make iGVT-g a great component in i915 to support graphics virtualization. Thanks!
Bing Niu (1):
drm/i915: Introduce host graphics memory partition for GVT-g
Zhi Wang (14):
drm/i915: factor out i915_pvinfo.h drm/i915/gvt: Introduce the basic architecture of GVT-g drm/i915: factor out alloc_context_idr() and
__i915_gem_create_context()
drm/i915: factor out __create_legacy_hw_context() drm/i915: let __i915_gem_context_create() takes context creation
params
drm/i915: factor out __intel_lr_context_deferred_alloc() drm/i915: Support per-PPGTT address space mode drm/i915: generate address mode bit from PPGTT instance drm/i915: update PDPs by condition when submit the LRC context drm/i915: Introduce execlist context status change notification drm/i915: Support context single submission
drm/i915: Introduce GVT context creation API drm/i915: factor out and expose i915_steal_fence() drm/i915: expose i915_find_fence_reg()
drivers/gpu/drm/i915/Kconfig | 15 +++ drivers/gpu/drm/i915/Makefile | 2 + drivers/gpu/drm/i915/gvt/Makefile | 5 + drivers/gpu/drm/i915/gvt/debug.h | 36 +++++ drivers/gpu/drm/i915/gvt/gvt.c | 230 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/gvt/gvt.h | 84 ++++++++++++ drivers/gpu/drm/i915/gvt/hypercall.h | 35 +++++ drivers/gpu/drm/i915/gvt/mpt.h | 51 +++++++ drivers/gpu/drm/i915/i915_dma.c | 15 +++ drivers/gpu/drm/i915/i915_drv.h | 41 ++++++ drivers/gpu/drm/i915/i915_gem_context.c | 204 ++++++++++++++++++++-------- drivers/gpu/drm/i915/i915_gem_fence.c | 46 +++++-- drivers/gpu/drm/i915/i915_gem_gtt.c | 92 +++++++------ drivers/gpu/drm/i915/i915_gem_gtt.h | 3 + drivers/gpu/drm/i915/i915_pvinfo.h | 113 ++++++++++++++++ drivers/gpu/drm/i915/i915_vgpu.c | 31 ++++- drivers/gpu/drm/i915/i915_vgpu.h | 88 +----------- drivers/gpu/drm/i915/intel_gvt.c | 148 ++++++++++++++++++++ drivers/gpu/drm/i915/intel_gvt.h | 57 ++++++++ drivers/gpu/drm/i915/intel_lrc.c | 146 ++++++++++++++------ drivers/gpu/drm/i915/intel_lrc.h | 15 +++ 21 files changed, 1216 insertions(+), 241 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/i915_pvinfo.h create mode 100644 drivers/gpu/drm/i915/intel_gvt.c create mode 100644 drivers/gpu/drm/i915/intel_gvt.h
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v3 1/15 drm/i915: factor out i915_pvinfo.h
As the PVINFO page definition is used by both GVT-g guest (vGPU) and GVT-g host (GVT-g kernel device model), factor it out for better code structure.
v3:
Take Joonas's comments:
- Use offsetof to calculate the member offset of PVINFO structure
--- drivers/gpu/drm/i915/i915_pvinfo.h | 113 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_vgpu.h | 86 +--------------------------- 2 files changed, 114 insertions(+), 85 deletions(-) create mode 100644 drivers/gpu/drm/i915/i915_pvinfo.h
drivers/gpu/drm/i915/i915_pvinfo.h new file +113 -0
@@ -0,0 +1,113 @@ +/* +* Copyright(c) 2011-2016 Intel Corporation. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*/ + +#ifndef _I915_PVINFO_H_ +#define _I915_PVINFO_H_ + +/* The MMIO offset of the shared info between guest and host emulator */ +#define VGT_PVINFO_PAGE 0x78000 +#define VGT_PVINFO_SIZE 0x1000 + +/* +* The following structure pages are defined in GEN MMIO space +* for virtualization. (One page for now) +*/ +#define VGT_MAGIC 0x4776544776544776ULL/* 'vGTvGTvG' */ +#define VGT_VERSION_MAJOR 1 +#define VGT_VERSION_MINOR 0 + +#define INTEL_VGT_IF_VERSION_ENCODE (major, minor) ((major) << 16 | (minor)) +#define INTEL_VGT_IF_VERSION \ + INTEL_VGT_IF_VERSION_ENCODE(VGT_VERSION_MAJOR, VGT_VERSION_MINOR) + +/* +* notifications from guest to vgpu device model +*/ +enum vgt_g2v_type { +VGT_G2V_PPGTT_L3_PAGE_TABLE_CREATE =2 , +VGT_G2V_PPGTT_L3_PAGE_TABLE_DESTROY , +VGT_G2V_PPGTT_L4_PAGE_TABLE_CREATE , +VGT_G2V_PPGTT_L4_PAGE_TABLE_DESTROY , +VGT_G2V_EXECLIST_CONTEXT_CREATE , +VGT_G2V_EXECLIST_CONTEXT_DESTROY , +VGT_G2V_MAX , +}; + +struct vgt_if { +uint64_t magic;/* VGT_MAGIC */ +uint16_t version_major; +uint16_t version_minor; +uint32_t vgt_id;/* ID of vGT instance */ +uint32_t rsv1[12 ];/* pad to offset 0x40 */ +/* +* Data structure to describe the balooning info of resources. +* Each VM can only have one portion of continuous area for now. +* (May support scattered resource in future) +* (starting from offset 0x40) +*/ +struct { +/* Aperture register balooning */ +struct { +uint32_t base; +uint32_t size; + } mappable_gmadr;/* aperture */ +/* GMADR register balooning */ +struct { +uint32_t base; +uint32_t size; + } nonmappable_gmadr;/* non aperture */ +/* allowed fence registers */ +uint32_t fence_num; +uint32_t rsv2[3 ]; + } avail_rs;/* available/assigned resource */ +uint32_t rsv3[0x200 -24 ];/* pad to half page */ +/* +* The bottom half page is for response from Gfx driver to hypervisor. +*/ +uint32_t rsv4; +uint32_t display_ready;/* ready for display owner switch */ + +uint32_t rsv5[4 ]; + +uint32_t g2v_notify; +uint32_t rsv6[7 ]; + +struct { +uint32_t lo; +uint32_t hi; + } pdp[4 ]; + +uint32_t execlist_context_descriptor_lo; +uint32_t execlist_context_descriptor_hi; + +uint32_t rsv7[0x200 -24 ];/* pad to one page */ +} __packed; + +#define vgtif_reg (x) \ + _MMIO(VGT_PVINFO_PAGE + offsetof(struct vgt_if, x)) + +/* vGPU display status to be used by the host side */ +#define VGT_DRV_DISPLAY_NOT_READY 0 +#define VGT_DRV_DISPLAY_READY 1/* ready for display switch */ + +#endif /* _I915_PVINFO_H_ */
drivers/gpu/drm/i915/i915_vgpu.h +1 -85
92 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v3 2/15 drm/i915/gvt: Introduce the basic architecture of GVT-g
In reply to Zhi WangThis patch introduces the very basic framework of GVT-g device model, includes basic prototypes, definitions, 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.
--- drivers/gpu/drm/i915/Kconfig | 15 +++ drivers/gpu/drm/i915/Makefile | 2 + drivers/gpu/drm/i915/gvt/Makefile | 5 + drivers/gpu/drm/i915/gvt/debug.h | 36 ++++++ drivers/gpu/drm/i915/gvt/gvt.c | 231 +++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/gvt/gvt.h | 82 +++++++++++++ drivers/gpu/drm/i915/gvt/hypercall.h | 38 ++++++ drivers/gpu/drm/i915/gvt/mpt.h | 51 ++++++++ drivers/gpu/drm/i915/i915_dma.c | 15 +++ drivers/gpu/drm/i915/i915_drv.h | 12 ++ drivers/gpu/drm/i915/i915_gem_gtt.c | 11 +- drivers/gpu/drm/i915/i915_vgpu.c | 10 +- drivers/gpu/drm/i915/i915_vgpu.h | 2 +- drivers/gpu/drm/i915/intel_gvt.c | 120 ++++++++++++++++++ drivers/gpu/drm/i915/intel_gvt.h | 54 ++++++++ include/drm/i915_gvt.h | 32 +++++ 16 files changed, 706 insertions(+), 10 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 create mode 100644 include/drm/i915_gvt.h
drivers/gpu/drm/i915/Kconfig +15 -0
@@ -56,3 +56,18 @@ config DRM_I915_USERPTR selected to enabled full userptr support. If in doubt, say "Y". + +config DRM_I915_GVT + tristate "Intel GVT-g host driver" + depends on DRM_I915 + default n + help + Enabling GVT-g mediated graphics passthrough technique for Intel i915 + based integrated graphics card. With GVT-g, it's possible to have one + integrated i915 device shared by multiple VMs. Performance critical + opterations such as apperture accesses and ring buffer operations + are pass-throughed to VM, with a minimal set of conflicting resources + (e.g. display settings) mediated by vGT driver. The benefit of vGT + is on both the performance, given that each VM could directly operate + its aperture space and submit commands like running on native, and + the feature completeness, given that a true GEN hardware is exposed.
drivers/gpu/drm/i915/Makefile +2 -0
@@ -91,6 +91,8 @@ i915-y += dvo_ch7017.o \ intel_sdvo.o \ intel_tv.o +obj-$(CONFIG_DRM_I915_GVT) += intel_gvt.o gvt/ + # virtual gpu code i915-y += i915_vgpu.o
drivers/gpu/drm/i915/gvt/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +GVT_SOURCE := gvt.o + +ccflags-y += -I$(src) -I$(src)/.. -Wall -Werror -Wno-unused-function +i915_gvt-y := $(GVT_SOURCE) +obj-$(CONFIG_DRM_I915_GVT) += i915_gvt.o
drivers/gpu/drm/i915/gvt/debug.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* Copyright(c) 2011-2016 Intel Corporation. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*/ + +#ifndef __GVT_DEBUG_H__ +#define __GVT_DEBUG_H__ + +#define gvt_info(fmt, args...) \ + DRM_INFO("gvt: "fmt, ##args) + +#define gvt_err(fmt, args...) \ + DRM_ERROR("gvt: "fmt, ##args) + +#define gvt_dbg_core(fmt, args...) \ + DRM_DEBUG_DRIVER("gvt: core: "fmt, ##args) + +#endif
drivers/gpu/drm/i915/gvt/gvt.c new file +231 -0
231 lines not on this page · raw message
drivers/gpu/drm/i915/gvt/gvt.h new file +82 -0
82 lines not on this page · raw message
drivers/gpu/drm/i915/gvt/hypercall.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* Copyright(c) 2011-2016 Intel Corporation. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*/ + +#ifndef _GVT_HYPERCALL_H_ +#define _GVT_HYPERCALL_H_ + +/* +* Specific GVT-g MPT modules function collections. Currently GVT-g supports +* both Xen and KVM by providing dedicated hypervisor-related MPT modules. +*/ +struct gvt_kernel_dm { +int (*detect_host)(void ); +}; + +extern struct gvt_kernel_dm xengt_kdm; +extern struct gvt_kernel_dm kvmgt_kdm; + +#endif /* _GVT_HYPERCALL_H_ */
drivers/gpu/drm/i915/gvt/mpt.h new file +51 -0
51 lines not on this page · raw message
drivers/gpu/drm/i915/i915_dma.c +15 -0
@@ -35,6 +35,7 @@#include "intel_drv.h" #include <drm/i915_drm.h> #include "i915_drv.h" +#include "intel_gvt.h" #include "i915_vgpu.h" #include "i915_trace.h" #include <linux/pci.h>
@@ -1045,6 +1046,10 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)intel_uncore_init (dev); + ret =intel_gvt_init (dev); +if (ret) + goto out_gvt_cleanup; + ret =i915_gem_gtt_init (dev);if (ret) goto out_uncore_fini;
@@ -1135,6 +1140,12 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) goto out_power_well; } + ret =intel_gvt_post_init (dev); +if (ret) { +DRM_ERROR ("failed to post init pgt device\n" ); + goto out_power_well; + } +/* * Notify a valid surface after modesetting, * when running inside a VM.
@@ -1176,6 +1187,8 @@ out_gem_unload:io_mapping_free (dev_priv->gtt.mappable); out_gtt:i915_global_gtt_cleanup (dev); +out_gvt_cleanup: +intel_gvt_cleanup (dev); out_uncore_fini:intel_uncore_fini (dev);i915_mmio_cleanup (dev);
@@ -1223,6 +1236,8 @@ int i915_driver_unload(struct drm_device *dev)intel_modeset_cleanup (dev); +intel_gvt_cleanup (dev); +/* * free the memory space allocated for the child device * config parsed from VBT
drivers/gpu/drm/i915/i915_drv.h +12 -0
@@ -1709,6 +1709,10 @@ struct i915_workarounds {u32 hw_whitelist_count[I915_NUM_RINGS ]; }; +struct i915_gvt { +void *gvt_device; +}; +struct i915_virtual_gpu {bool active; };
@@ -1748,6 +1752,8 @@ struct drm_i915_private {struct i915_virtual_gpu vgpu; +struct i915_gvt gvt; +struct intel_guc guc;struct intel_csr csr;
@@ -2785,6 +2791,12 @@ void intel_uncore_forcewake_get__locked(struct drm_i915_private *dev_priv,void intel_uncore_forcewake_put__locked (struct drm_i915_private *dev_priv,enum forcewake_domains domains);void assert_forcewakes_inactive (struct drm_i915_private *dev_priv); + +static inline bool intel_gvt_active (struct drm_device *dev) +{ +return to_i915 (dev)->gvt.gvt_device ? true : false; +} +static inline bool intel_vgpu_active (struct drm_device *dev) {return to_i915 (dev)->vgpu.active;
drivers/gpu/drm/i915/i915_gem_gtt.c +4 -7
@@ -2734,11 +2734,9 @@ static int i915_gem_setup_global_gtt(struct drm_device *dev,i915_address_space_init (ggtt_vm, dev_priv); ggtt_vm->total +=PAGE_SIZE ; -if (intel_vgpu_active (dev)) { - ret =intel_vgt_balloon (dev); -if (ret) -return ret; - } + ret =intel_vgt_balloon (dev); +if (ret) +return ret;if (!HAS_LLC (dev)) ggtt_vm->mm.color_adjust = i915_gtt_color_adjust;
@@ -2833,8 +2831,7 @@ void i915_global_gtt_cleanup(struct drm_device *dev)i915_gem_cleanup_stolen (dev);if (drm_mm_initialized (&vm->mm)) { -if (intel_vgpu_active (dev)) -intel_vgt_deballoon (); +intel_vgt_deballoon (dev);drm_mm_takedown (&vm->mm);list_del (&vm->global_link);
drivers/gpu/drm/i915/i915_vgpu.c +8 -2
@@ -102,10 +102,13 @@ static struct _balloon_info_ bl_info;* This function is called to deallocate the ballooned-out graphic memory, when * driver is unloaded or when ballooning fails. */ -void intel_vgt_deballoon (void ) +void intel_vgt_deballoon (struct drm_device *dev) {int i; +if (!intel_vgpu_active (dev) && !intel_gvt_active (dev)) +return ; +DRM_DEBUG ("VGT deballoon.\n" );for (i =0 ; i <4 ; i++) {
@@ -188,6 +191,9 @@ int intel_vgt_balloon(struct drm_device *dev)unsigned long unmappable_base, unmappable_size, unmappable_end;int ret; +if (!intel_vgpu_active (dev) && !intel_gvt_active (dev)) +return 0 ; + mappable_base =I915_READ (vgtif_reg (avail_rs.mappable_gmadr.base)); mappable_size =I915_READ (vgtif_reg (avail_rs.mappable_gmadr.size)); unmappable_base =I915_READ (vgtif_reg (avail_rs.nonmappable_gmadr.base));
@@ -259,6 +265,6 @@ int intel_vgt_balloon(struct drm_device *dev) err:DRM_ERROR ("VGT balloon fail\n" ); -intel_vgt_deballoon (); +intel_vgt_deballoon (dev);return ret; }
drivers/gpu/drm/i915/i915_vgpu.h +1 -1
@@ -28,6 +28,6 @@extern void i915_check_vgpu (struct drm_device *dev);extern int intel_vgt_balloon (struct drm_device *dev); -extern void intel_vgt_deballoon (void ); +extern void intel_vgt_deballoon (struct drm_device *dev);#endif /* _I915_VGPU_H_ */
drivers/gpu/drm/i915/intel_gvt.c new file +120 -0
120 lines not on this page · raw message
drivers/gpu/drm/i915/intel_gvt.h new file +54 -0
54 lines not on this page · raw message
include/drm/i915_gvt.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Copyright(c) 2011-2016 Intel Corporation. All rights reserved. +* All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sub license, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice (including the +* next paragraph) shall be included in all copies or substantial portions +* of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ +#ifndef _I915_GVT_H +#define _I915_GVT_H + +extern void *gvt_create_device (void *dev); +extern int gvt_post_init_device (void *gvt_device); +extern void gvt_destroy_device (void *gvt_device); + +#endif /* _I915_GVT_H */
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v3 3/15 drm/i915: Introduce host graphics memory partition for GVT-g
In reply to Zhi WangFrom: Bing Niu <[email protected]>
This patch introduces host graphics memory partition when GVT-g is enabled.
Under GVT-g, i915 host driver only owned limited graphics resources, others are managed by GVT-g resource allocator and kept for other vGPUs.
v3:
- Remove fence partition, will use i915 fence stealing in future.(Kevin)
- Santinize GVT host gm kernel parameters. (Joonas)
v2:
- Address all coding-style comments from Joonas previously.
- Fix errors and warnning reported by checkpatch.pl. (Joonas)
- Move the graphs into the header files. (Daniel)
--- drivers/gpu/drm/i915/i915_drv.h | 22 ++++++++++++++++++++ drivers/gpu/drm/i915/i915_vgpu.c | 21 ++++++++++++++++---- drivers/gpu/drm/i915/intel_gvt.c | 43 ++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_gvt.h | 2 ++ 4 files changed, 84 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +22 -0
@@ -1709,8 +1709,30 @@ struct i915_workarounds {u32 hw_whitelist_count[I915_NUM_RINGS ]; }; +/* +* Under GVT-g, i915 host driver only owned limited graphics resources, +* others are managed by GVT-g resource allocator and kept for other vGPUs. +* +* For graphics memory space partition, a typical layout looks like: +* +* +-------+-----------------------+------+-----------------------+ +* |* Host | *GVT-g Resource |* Host| *GVT-g Resource | +* | Owned | Allocator Managed | Owned| Allocator Managed | +* | | | | | +* +---------------+-------+----------------------+-------+-------+ +* | | | | | | | | | +* | i915 | vm 1 | vm 2 | vm 3 | i915 | vm 1 | vm 2 | vm 3 | +* | | | | | | | | | +* +-------+-------+-------+--------------+-------+-------+-------+ +* | Aperture | Hidden | +* +-------------------------------+------------------------------+ +* | GGTT memory space | +* +--------------------------------------------------------------+ +*/ struct i915_gvt {void *gvt_device; +u64 low_gm_size; +u64 high_gm_size; };struct i915_virtual_gpu {
drivers/gpu/drm/i915/i915_vgpu.c +17 -4
@@ -194,10 +194,23 @@ int intel_vgt_balloon(struct drm_device *dev)if (!intel_vgpu_active (dev) && !intel_gvt_active (dev))return 0 ; - mappable_base =I915_READ (vgtif_reg (avail_rs.mappable_gmadr.base)); - mappable_size =I915_READ (vgtif_reg (avail_rs.mappable_gmadr.size)); - unmappable_base =I915_READ (vgtif_reg (avail_rs.nonmappable_gmadr.base)); - unmappable_size =I915_READ (vgtif_reg (avail_rs.nonmappable_gmadr.size)); +if (intel_gvt_active (dev)) { + mappable_base =0 ; + mappable_size = dev_priv->gvt.low_gm_size; + unmappable_base = dev_priv->gtt.mappable_end; + unmappable_size = dev_priv->gvt.high_gm_size; + }else if (intel_vgpu_active (dev)) { + mappable_base =I915_READ ( +vgtif_reg (avail_rs.mappable_gmadr.base)); + mappable_size =I915_READ ( +vgtif_reg (avail_rs.mappable_gmadr.size)); + unmappable_base =I915_READ ( +vgtif_reg (avail_rs.nonmappable_gmadr.base)); + unmappable_size =I915_READ ( +vgtif_reg (avail_rs.nonmappable_gmadr.size)); + }else { +return -ENODEV ; + } mappable_end = mappable_base + mappable_size; unmappable_end = unmappable_base + unmappable_size;
drivers/gpu/drm/i915/intel_gvt.c +43 -0
61 lines not on this page · raw message
drivers/gpu/drm/i915/intel_gvt.h +2 -0
@@ -30,6 +30,8 @@struct gvt_kernel_params {bool enable; +char *low_gm_size; +char *high_gm_size; };extern struct gvt_kernel_params gvt;
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v3 4/15 drm/i915: factor out alloc_context_idr() and __i915_gem_create_context()
In reply to Zhi WangFor flexible GEM context creation, we factor out __i915_gem_create_context as the core logic of creation a GEM context. After the refactor, it more likes a context creation service, which is able to create context by explicit requirement of upper level components.
For the assumptions in original implementation, we keep them in the upper level wrapper: i915_gem_create_context().
alloc_context_idr() is another function factored out to setup a IDR for ordinary GEM context. Some context, e.g. GVT context, will not be manipulated by user space application, so it doesn't need an IDR.
--- drivers/gpu/drm/i915/i915_gem_context.c | 62 ++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 17 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +45 -17
@@ -235,17 +235,7 @@ __create_hw_context(struct drm_device *dev, ctx->legacy_hw_ctx.rcs_state = obj; } -/* Default context will never have a file_priv */ -if (file_priv !=NULL ) { - ret =idr_alloc (&file_priv->context_idr, ctx, -DEFAULT_CONTEXT_HANDLE ,0 ,GFP_KERNEL ); -if (ret <0 ) - goto err_out; - }else - ret =DEFAULT_CONTEXT_HANDLE ; - ctx->file_priv = file_priv; - ctx->user_handle = ret;/* NB: Mark all slices as needing a remap so that when the context first * loads it will restore whatever remap state already exists. If there * is no remap info, it will be a NOP. */
@@ -260,13 +250,8 @@ err_out:return ERR_PTR (ret); } -/** -* The default context needs to exist per ring that uses contexts. It stores the -* context state of the GPU for applications that don't utilize HW contexts, as -* well as an idle case. -*/ static struct intel_context * -i915_gem_create_context (struct drm_device *dev, +__i915_gem_create_context (struct drm_device *dev,struct drm_i915_file_private *file_priv) {const bool is_global_default_ctx = file_priv ==NULL ;
@@ -316,11 +301,54 @@ err_unpin:if (is_global_default_ctx && ctx->legacy_hw_ctx.rcs_state)i915_gem_object_ggtt_unpin (ctx->legacy_hw_ctx.rcs_state); err_destroy: -idr_remove (&file_priv->context_idr, ctx->user_handle);i915_gem_context_unreference (ctx);return ERR_PTR (ret); } +static inline int alloc_context_idr (struct drm_device *dev, +struct intel_context *ctx) +{ +int ret; + +/* Default context will never have a file_priv */ +if (ctx->file_priv !=NULL ) { + ret =idr_alloc (&ctx->file_priv->context_idr, ctx, +DEFAULT_CONTEXT_HANDLE ,0 ,GFP_KERNEL ); +if (ret <0 ) +return ret; + }else { + ret =DEFAULT_CONTEXT_HANDLE ; + } + + ctx->user_handle = ret; +return 0 ; +} + +/** +* The default context needs to exist per ring that uses contexts. It stores the +* context state of the GPU for applications that don't utilize HW contexts, as +* well as an idle case. +*/ +static struct intel_context * +i915_gem_create_context (struct drm_device *dev, +struct drm_i915_file_private *file_priv) +{ +struct intel_context *ctx; +int ret; + + ctx =__i915_gem_create_context (dev, file_priv); +if (IS_ERR (ctx)) +return ctx; + + ret =alloc_context_idr (dev, ctx); +if (ret <0 ) { +i915_gem_context_unreference (ctx); +return ERR_PTR (ret); + } + +return ctx; +} +static void i915_gem_context_unpin (struct intel_context *ctx,struct intel_engine_cs *engine) {
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v3 5/15 drm/i915: factor out __create_legacy_hw_context()
In reply to Zhi WangAs creating the legacy HW context has become into an option in GEM context creating service and will only be used in legacy ring buffer mode, we factor out __create_legacy_hw_context() from __create_hw_context() for better code structure.
--- drivers/gpu/drm/i915/i915_gem_context.c | 43 ++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +24 -19
@@ -209,13 +209,26 @@ i915_gem_alloc_context_obj(struct drm_device *dev, size_t size)return obj; } +static int __create_legacy_hw_context (struct drm_device *dev, +struct intel_context *ctx) +{ +struct drm_i915_private *dev_priv =to_i915 (dev); +struct drm_i915_gem_object *obj = +i915_gem_alloc_context_obj (dev, dev_priv->hw_context_size); + +if (IS_ERR (obj)) +return PTR_ERR (obj); + + ctx->legacy_hw_ctx.rcs_state = obj; +return 0 ; +} +static struct intel_context *__create_hw_context (struct drm_device *dev,struct drm_i915_file_private *file_priv) {struct drm_i915_private *dev_priv = dev->dev_private;struct intel_context *ctx; -int ret; ctx =kzalloc (sizeof (*ctx),GFP_KERNEL );if (ctx ==NULL )
@@ -224,37 +237,23 @@ __create_hw_context(struct drm_device *dev,kref_init (&ctx->ref);list_add_tail (&ctx->link, &dev_priv->context_list); ctx->i915 = dev_priv; - -if (dev_priv->hw_context_size) { -struct drm_i915_gem_object *obj = -i915_gem_alloc_context_obj (dev, dev_priv->hw_context_size); -if (IS_ERR (obj)) { - ret =PTR_ERR (obj); - goto err_out; - } - ctx->legacy_hw_ctx.rcs_state = obj; - } - ctx->file_priv = file_priv;/* NB: Mark all slices as needing a remap so that when the context first * loads it will restore whatever remap state already exists. If there * is no remap info, it will be a NOP. */ ctx->remap_slice = (1 <<NUM_L3_SLICES (dev)) -1 ; - ctx->hang_stats.ban_period_seconds =DRM_I915_CTX_BAN_PERIOD ;return ctx; - -err_out: -i915_gem_context_unreference (ctx); -return ERR_PTR (ret); }static struct intel_context *__i915_gem_create_context (struct drm_device *dev,struct drm_i915_file_private *file_priv) { +struct drm_i915_private *dev_priv =to_i915 (dev);const bool is_global_default_ctx = file_priv ==NULL ; +const bool is_legacy_ctx = !!dev_priv->hw_context_size;struct intel_context *ctx;int ret =0 ;
@@ -264,7 +263,13 @@ __i915_gem_create_context(struct drm_device *dev,if (IS_ERR (ctx))return ctx; -if (is_global_default_ctx && ctx->legacy_hw_ctx.rcs_state) { +if (is_legacy_ctx) { + ret =__create_legacy_hw_context (dev, ctx); +if (ret) + goto err_destroy; + } + +if (is_global_default_ctx && is_legacy_ctx) {/* We may need to do things with the shrinker which * require us to immediately switch back to the default * context. This can cause a problem as pinning the
@@ -298,7 +303,7 @@ __i915_gem_create_context(struct drm_device *dev,return ctx; err_unpin: -if (is_global_default_ctx && ctx->legacy_hw_ctx.rcs_state) +if (is_global_default_ctx && is_legacy_ctx)i915_gem_object_ggtt_unpin (ctx->legacy_hw_ctx.rcs_state); err_destroy:i915_gem_context_unreference (ctx);
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v3 6/15 drm/i915: let __i915_gem_context_create() takes context creation params
In reply to Zhi WangLet the core logic of context creation service creates the GEM context by context creation params.
Now it provides following options for context creation:
- Need to create legacy context for this GEM context?
- Need to create PPGTT instance for this GEM context?
- Need to treat this context as the global default context?
And for all the assumptions in the original implementation, we keep them in the upper-level wrapper.
--- drivers/gpu/drm/i915/i915_gem_context.c | 71 ++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 28 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +43 -28
@@ -223,6 +223,13 @@ static int __create_legacy_hw_context(struct drm_device *dev,return 0 ; } +struct i915_gem_context_create_params { +struct drm_i915_file_private *file_priv; +bool has_legacy_ctx; +bool has_ppgtt; +bool is_global_default_ctx; +}; +static struct intel_context *__create_hw_context (struct drm_device *dev,struct drm_i915_file_private *file_priv)
@@ -249,44 +256,43 @@ __create_hw_context(struct drm_device *dev,static struct intel_context *__i915_gem_create_context (struct drm_device *dev, -struct drm_i915_file_private *file_priv) +struct i915_gem_context_create_params *params) { -struct drm_i915_private *dev_priv =to_i915 (dev); -const bool is_global_default_ctx = file_priv ==NULL ; -const bool is_legacy_ctx = !!dev_priv->hw_context_size;struct intel_context *ctx;int ret =0 ;BUG_ON (!mutex_is_locked (&dev->struct_mutex)); - ctx =__create_hw_context (dev, file_priv); + ctx =__create_hw_context (dev, params->file_priv);if (IS_ERR (ctx))return ctx; -if (is_legacy_ctx) { +if (params->has_legacy_ctx) { ret =__create_legacy_hw_context (dev, ctx);if (ret) goto err_destroy; - } -if (is_global_default_ctx && is_legacy_ctx) { -/* We may need to do things with the shrinker which -* require us to immediately switch back to the default -* context. This can cause a problem as pinning the -* default context also requires GTT space which may not -* be available. To avoid this we always pin the default -* context. -*/ - ret =i915_gem_obj_ggtt_pin (ctx->legacy_hw_ctx.rcs_state, -get_context_alignment (dev),0 ); -if (ret) { -DRM_DEBUG_DRIVER ("Couldn't pin %d\n" , ret); - goto err_destroy; +if (params->is_global_default_ctx) { +/* We may need to do things with the shrinker +* which require us to immediately switch back to +* the default context. This can cause a problem as +* pinning the default context also requires GTT +* space which may not be available. To avoid this +* we always pin the default context. +*/ + ret =i915_gem_obj_ggtt_pin ( + ctx->legacy_hw_ctx.rcs_state, +get_context_alignment (dev),0 ); +if (ret) { +DRM_DEBUG_DRIVER ("Couldn't pin %d\n" , ret); + goto err_destroy; + } } } -if (USES_FULL_PPGTT (dev)) { -struct i915_hw_ppgtt *ppgtt =i915_ppgtt_create (dev, file_priv); +if (params->has_ppgtt) { +struct i915_hw_ppgtt *ppgtt =i915_ppgtt_create (dev, + params->file_priv);if (IS_ERR_OR_NULL (ppgtt)) { DRM_DEBUG_DRIVER("PPGTT setup failed (%ld)\n",
@@ -303,7 +309,7 @@ __i915_gem_create_context(struct drm_device *dev,return ctx; err_unpin: -if (is_global_default_ctx && is_legacy_ctx) +if (params->is_global_default_ctx && params->has_legacy_ctx)i915_gem_object_ggtt_unpin (ctx->legacy_hw_ctx.rcs_state); err_destroy:i915_gem_context_unreference (ctx);
@@ -311,12 +317,12 @@ err_destroy: }static inline int alloc_context_idr (struct drm_device *dev, -struct intel_context *ctx) +struct intel_context *ctx, +struct i915_gem_context_create_params *params) {int ret; -/* Default context will never have a file_priv */ -if (ctx->file_priv !=NULL ) { +if (params->is_global_default_ctx) { ret =idr_alloc (&ctx->file_priv->context_idr, ctx,DEFAULT_CONTEXT_HANDLE ,0 ,GFP_KERNEL );if (ret <0 )
@@ -338,14 +344,23 @@ static struct intel_context * i915_gem_create_context(struct drm_device *dev, struct drm_i915_file_private *file_priv) { + struct drm_i915_private *dev_priv = to_i915(dev); +struct i915_gem_context_create_params params;struct intel_context *ctx;int ret; - ctx =__i915_gem_create_context (dev, file_priv); +memset (¶ms,0 ,sizeof (params)); + + params.file_priv = file_priv; + params.has_legacy_ctx = !!dev_priv->hw_context_size; + params.has_ppgtt =USES_FULL_PPGTT (dev); + params.is_global_default_ctx = (file_priv ==NULL ); + + ctx =__i915_gem_create_context (dev, ¶ms);if (IS_ERR (ctx))return ctx; - ret =alloc_context_idr (dev, ctx); + ret =alloc_context_idr (dev, ctx, ¶ms);if (ret <0 ) {i915_gem_context_unreference (ctx);return ERR_PTR (ret);
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v3 7/15 drm/i915: factor out __intel_lr_context_deferred_alloc()
In reply to Zhi WangFor flexible LRC context creation, we factor out the core logic of LRC context creation as __intel_lr_context_deferred_alloc().
For the hard-coded LRC context configurations, we keep them in the upper-level function intel_lr_context_deferred_alloc().
--- drivers/gpu/drm/i915/intel_lrc.c | 46 ++++++++++++++++++++++++++++++---------- drivers/gpu/drm/i915/intel_lrc.h | 8 +++++++ 2 files changed, 43 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +35 -11
@@ -2525,22 +2525,19 @@ static void lrc_setup_hardware_status_page(struct intel_engine_cs *ring, }/** -* intel_lr_context_deferred_alloc() - create the LRC specific bits of a context +* __intel_lr_context_deferred_alloc() - core logic of creating a LRC context * @ctx: LR context to create. -* @ring: engine to be used with the context. +* @params: parameters to specify configurable options of the context. * -* This function can be called more than once, with different engines, if we plan -* to use the context with them. The context backing objects and the ringbuffers -* (specially the ringbuffer backing objects) suck a lot of memory up, and that's why -* the creation is a deferred call: it's better to make sure first that we need to use -* a given ring with the context. +* This function is the core logic of creating and initializing a LRC context * * Return: non-zero on error. */ -int intel_lr_context_deferred_alloc (struct intel_context *ctx, -struct intel_engine_cs *ring) +int __intel_lr_context_deferred_alloc (struct intel_context *ctx, +struct intel_lr_context_alloc_params *params) { +struct intel_engine_cs *ring = params->ring;struct drm_device *dev = ring->dev;struct drm_i915_gem_object *ctx_obj;uint32_t context_size;
@@ -2561,7 +2558,7 @@ int intel_lr_context_deferred_alloc(struct intel_context *ctx,return -ENOMEM ; } - ringbuf =intel_engine_create_ringbuffer (ring,4 *PAGE_SIZE ); + ringbuf =intel_engine_create_ringbuffer (ring, params->ringbuffer_size);if (IS_ERR (ringbuf)) { ret =PTR_ERR (ringbuf); goto error_deref_obj;
@@ -2576,7 +2573,7 @@ int intel_lr_context_deferred_alloc(struct intel_context *ctx, ctx->engine[ring->id].ringbuf = ringbuf; ctx->engine[ring->id].state = ctx_obj; -if (ctx != ctx->i915->kernel_context && ring->init_context) { +if (params->ctx_needs_init && ring->init_context) {struct drm_i915_gem_request *req; req =i915_gem_request_alloc (ring, ctx);
@@ -2606,6 +2603,33 @@ error_deref_obj:return ret; } +/** +* intel_lr_context_deferred_alloc() - create the LRC specific bits of a context +* @ctx: LR context to create. +* @ring: engine to be used with the context. +* +* This function can be called more than once, with different engines, if we +* plan to use the context with them. The context backing objects and the +* ringbuffers (specially the ringbuffer backing objects) suck a lot of memory +* up, and that's why the creation is a deferred call: it's better to make sure +* firstthat we need to use a given ring with the context. +* +* Return: non-zero on error. +*/ +int intel_lr_context_deferred_alloc (struct intel_context *ctx, +struct intel_engine_cs *ring) +{ +struct intel_lr_context_alloc_params params; + +memset (¶ms,0 ,sizeof (params)); + + params.ring = ring; + params.ringbuffer_size =4 *PAGE_SIZE ; + params.ctx_needs_init = (ctx != ctx->i915->kernel_context); + +return __intel_lr_context_deferred_alloc (ctx, ¶ms); +} +void intel_lr_context_reset (struct drm_device *dev,struct intel_context *ctx) {
drivers/gpu/drm/i915/intel_lrc.h +8 -0
@@ -97,10 +97,18 @@ static inline void intel_logical_ring_emit_reg(struct intel_ringbuffer *ringbuf,#define LRC_PPHWSP_PN (LRC_GUCSHR_PN + 1)#define LRC_STATE_PN (LRC_PPHWSP_PN + 1) +struct intel_lr_context_alloc_params { +struct intel_engine_cs *ring; +u32 ringbuffer_size; +bool ctx_needs_init; +}; +void intel_lr_context_free (struct intel_context *ctx);uint32_t intel_lr_context_size (struct intel_engine_cs *ring);int intel_lr_context_deferred_alloc (struct intel_context *ctx,struct intel_engine_cs *ring); +int __intel_lr_context_deferred_alloc (struct intel_context *ctx, +struct intel_lr_context_alloc_params *params);void intel_lr_context_unpin (struct intel_context *ctx,struct intel_engine_cs *engine); void intel_lr_context_reset(struct drm_device *dev,
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v3 8/15 drm/i915: Support per-PPGTT address space mode
In reply to Zhi WangPreviously the address space mode of each PPGTT instance is hard-coded to host system configuration, e.g. if the host system is configured to use 48bit full PPGTT, then address space mode of all PPGTT instances is 48bit.
Per Daniel and Kevin's advice, GVT-g will leverage i915 PPGTT interface to populate its shadow PPGTT page table. Under GVT-g the address space mode of PPGTT instances could be various, some guest may use 32bit, some guest may use 48bit.
We store the address space mode into i915_hw_ppgtt, and let i915 page table manipulation routines / LRC context population routines read the address space mode from it instead of the system configuration.
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 81 ++++++++++++++++++++----------------- drivers/gpu/drm/i915/i915_gem_gtt.h | 3 ++ drivers/gpu/drm/i915/intel_lrc.c | 6 +-- 3 files changed, 51 insertions(+), 39 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +45 -36
@@ -564,22 +564,22 @@ static void __pdp_fini(struct i915_page_directory_pointer *pdp) }static struct -i915_page_directory_pointer *alloc_pdp (struct drm_device *dev) +i915_page_directory_pointer *alloc_pdp (struct i915_hw_ppgtt *ppgtt) {struct i915_page_directory_pointer *pdp;int ret = -ENOMEM ; -WARN_ON (!USES_FULL_48BIT_PPGTT (dev)); +WARN_ON (!IS_48BIT_PPGTT (ppgtt)); pdp =kzalloc (sizeof (*pdp),GFP_KERNEL );if (!pdp)return ERR_PTR (-ENOMEM ); - ret =__pdp_init (dev, pdp); + ret =__pdp_init (ppgtt->base.dev, pdp);if (ret) goto fail_bitmap; - ret =setup_px (dev, pdp); + ret =setup_px (ppgtt->base.dev, pdp);if (ret) goto fail_page_m;
@@ -593,12 +593,12 @@ fail_bitmap:return ERR_PTR (ret); } -static void free_pdp (struct drm_device *dev, +static void free_pdp (struct i915_hw_ppgtt *ppgtt,struct i915_page_directory_pointer *pdp) {__pdp_fini (pdp); -if (USES_FULL_48BIT_PPGTT (dev)) { -cleanup_px (dev, pdp); +if (IS_48BIT_PPGTT (ppgtt)) { +cleanup_px (ppgtt->base.dev, pdp);kfree (pdp); } }
@@ -632,7 +632,7 @@ gen8_setup_page_directory(struct i915_hw_ppgtt *ppgtt, {gen8_ppgtt_pdpe_t *page_directorypo; -if (!USES_FULL_48BIT_PPGTT (ppgtt->base.dev)) +if (!IS_48BIT_PPGTT (ppgtt))return ; page_directorypo =kmap_px (pdp);
@@ -648,7 +648,7 @@ gen8_setup_page_directory_pointer(struct i915_hw_ppgtt *ppgtt, {gen8_ppgtt_pml4e_t *pagemap =kmap_px (pml4); -WARN_ON (!USES_FULL_48BIT_PPGTT (ppgtt->base.dev)); +WARN_ON (!IS_48BIT_PPGTT (ppgtt)); pagemap[index] =gen8_pml4e_encode (px_dma (pdp),I915_CACHE_LLC );kunmap_px (ppgtt, pagemap); }
@@ -767,7 +767,7 @@ static void gen8_ppgtt_clear_range(struct i915_address_space *vm,gen8_pte_t scratch_pte =gen8_pte_encode (px_dma (vm->scratch_page),I915_CACHE_LLC , use_scratch); -if (!USES_FULL_48BIT_PPGTT (vm->dev)) { +if (!IS_48BIT_PPGTT (ppgtt)) {gen8_ppgtt_clear_pte_range (vm, &ppgtt->pdp, start, length, scratch_pte); }else {
@@ -835,7 +835,7 @@ static void gen8_ppgtt_insert_entries(struct i915_address_space *vm,__sg_page_iter_start (&sg_iter, pages->sgl,sg_nents (pages->sgl),0 ); -if (!USES_FULL_48BIT_PPGTT (vm->dev)) { +if (!IS_48BIT_PPGTT (ppgtt)) {gen8_ppgtt_insert_pte_entries (vm, &ppgtt->pdp, &sg_iter, start, cache_level); }else {
@@ -869,6 +869,8 @@ static void gen8_free_page_tables(struct drm_device *dev,static int gen8_init_scratch (struct i915_address_space *vm) { +struct i915_hw_ppgtt *ppgtt = + container_of(vm, struct i915_hw_ppgtt, base);struct drm_device *dev = vm->dev; vm->scratch_page =alloc_scratch_page (dev);
@@ -888,8 +890,8 @@ static int gen8_init_scratch(struct i915_address_space *vm)return PTR_ERR (vm->scratch_pd); } -if (USES_FULL_48BIT_PPGTT (dev)) { - vm->scratch_pdp =alloc_pdp (dev); +if (IS_48BIT_PPGTT (ppgtt)) { + vm->scratch_pdp =alloc_pdp (ppgtt);if (IS_ERR (vm->scratch_pdp)) {free_pd (dev, vm->scratch_pd);free_pt (dev, vm->scratch_pt);
@@ -900,7 +902,7 @@ static int gen8_init_scratch(struct i915_address_space *vm)gen8_initialize_pt (vm, vm->scratch_pt);gen8_initialize_pd (vm, vm->scratch_pd); -if (USES_FULL_48BIT_PPGTT (dev)) +if (IS_48BIT_PPGTT (ppgtt))gen8_initialize_pdp (vm, vm->scratch_pdp);return 0 ;
@@ -913,7 +915,7 @@ static int gen8_ppgtt_notify_vgt(struct i915_hw_ppgtt *ppgtt, bool create)struct drm_i915_private *dev_priv = dev->dev_private;int i; -if (USES_FULL_48BIT_PPGTT (dev)) { +if (IS_48BIT_PPGTT (ppgtt)) {u64 daddr =px_dma (&ppgtt->pml4);I915_WRITE (vgtif_reg (pdp[0 ].lo),lower_32_bits (daddr));
@@ -942,14 +944,17 @@ static void gen8_free_scratch(struct i915_address_space *vm) {struct drm_device *dev = vm->dev; -if (USES_FULL_48BIT_PPGTT (dev)) -free_pdp (dev, vm->scratch_pdp); +struct i915_hw_ppgtt *ppgtt = + container_of(vm, struct i915_hw_ppgtt, base); + +if (IS_48BIT_PPGTT (ppgtt)) +free_pdp (ppgtt, vm->scratch_pdp);free_pd (dev, vm->scratch_pd);free_pt (dev, vm->scratch_pt);free_scratch_page (dev, vm->scratch_page); } -static void gen8_ppgtt_cleanup_3lvl (struct drm_device *dev, +static void gen8_ppgtt_cleanup_3lvl (struct i915_hw_ppgtt *ppgtt,struct i915_page_directory_pointer *pdp) {int i;
@@ -958,11 +963,11 @@ static void gen8_ppgtt_cleanup_3lvl(struct drm_device *dev,if (WARN_ON (!pdp->page_directory[i]))continue ; -gen8_free_page_tables (dev, pdp->page_directory[i]); -free_pd (dev, pdp->page_directory[i]); +gen8_free_page_tables (ppgtt->base.dev, pdp->page_directory[i]); +free_pd (ppgtt->base.dev, pdp->page_directory[i]); } -free_pdp (dev, pdp); +free_pdp (ppgtt, pdp); }static void gen8_ppgtt_cleanup_4lvl (struct i915_hw_ppgtt *ppgtt)
@@ -973,7 +978,7 @@ static void gen8_ppgtt_cleanup_4lvl(struct i915_hw_ppgtt *ppgtt)if (WARN_ON (!ppgtt->pml4.pdps[i]))continue ; -gen8_ppgtt_cleanup_3lvl (ppgtt->base.dev, ppgtt->pml4.pdps[i]); +gen8_ppgtt_cleanup_3lvl (ppgtt, ppgtt->pml4.pdps[i]); }cleanup_px (ppgtt->base.dev, &ppgtt->pml4);
@@ -987,8 +992,8 @@ static void gen8_ppgtt_cleanup(struct i915_address_space *vm)if (intel_vgpu_active (vm->dev))gen8_ppgtt_notify_vgt (ppgtt, false); -if (!USES_FULL_48BIT_PPGTT (ppgtt->base.dev)) -gen8_ppgtt_cleanup_3lvl (ppgtt->base.dev, &ppgtt->pdp); +if (!IS_48BIT_PPGTT (ppgtt)) +gen8_ppgtt_cleanup_3lvl (ppgtt, &ppgtt->pdp);else gen8_ppgtt_cleanup_4lvl (ppgtt);
@@ -1133,7 +1138,8 @@ gen8_ppgtt_alloc_page_dirpointers(struct i915_address_space *vm,uint64_t length, unsigned long *new_pdps) { - struct drm_device *dev = vm->dev; + struct i915_hw_ppgtt *ppgtt = + container_of(vm, struct i915_hw_ppgtt, base);struct i915_page_directory_pointer *pdp;uint32_t pml4e;
@@ -1141,7 +1147,7 @@ gen8_ppgtt_alloc_page_dirpointers(struct i915_address_space *vm,gen8_for_each_pml4e (pdp, pml4, start, length, pml4e) {if (!test_bit (pml4e, pml4->used_pml4es)) { - pdp =alloc_pdp (dev); + pdp =alloc_pdp (ppgtt);if (IS_ERR (pdp)) goto unwind_out;
@@ -1159,7 +1165,7 @@ gen8_ppgtt_alloc_page_dirpointers(struct i915_address_space *vm, unwind_out:for_each_set_bit (pml4e, new_pdps,GEN8_PML4ES_PER_PML4 ) -free_pdp (dev, pml4->pdps[pml4e]); +free_pdp (ppgtt, pml4->pdps[pml4e]);return -ENOMEM ; }
@@ -1368,7 +1374,7 @@ static int gen8_alloc_va_range_4lvl(struct i915_address_space *vm, err_out:for_each_set_bit (pml4e, new_pdps,GEN8_PML4ES_PER_PML4 ) -gen8_ppgtt_cleanup_3lvl (vm->dev, pml4->pdps[pml4e]); +gen8_ppgtt_cleanup_3lvl (ppgtt, pml4->pdps[pml4e]);return ret; }
@@ -1379,7 +1385,7 @@ static int gen8_alloc_va_range(struct i915_address_space *vm,struct i915_hw_ppgtt *ppgtt = container_of(vm, struct i915_hw_ppgtt, base); -if (USES_FULL_48BIT_PPGTT (vm->dev)) +if (IS_48BIT_PPGTT (ppgtt))return gen8_alloc_va_range_4lvl (vm, &ppgtt->pml4, start, length);else return gen8_alloc_va_range_3lvl (vm, &ppgtt->pdp, start, length);
@@ -1450,7 +1456,7 @@ static void gen8_dump_ppgtt(struct i915_hw_ppgtt *ppgtt, struct seq_file *m)gen8_pte_t scratch_pte =gen8_pte_encode (px_dma (vm->scratch_page),I915_CACHE_LLC , true); -if (!USES_FULL_48BIT_PPGTT (vm->dev)) { +if (!IS_48BIT_PPGTT (ppgtt)) {gen8_dump_pdp (&ppgtt->pdp, start, length, scratch_pte, m); }else {uint64_t pml4e;
@@ -1501,7 +1507,7 @@ static int gen8_preallocate_top_level_pdps(struct i915_hw_ppgtt *ppgtt)* space. * */ -static int gen8_ppgtt_init (struct i915_hw_ppgtt *ppgtt) +static int gen8_ppgtt_init (struct i915_hw_ppgtt *ppgtt,int address_space_mode) {int ret;
@@ -1518,7 +1524,7 @@ static int gen8_ppgtt_init(struct i915_hw_ppgtt *ppgtt) ppgtt->base.bind_vma = ppgtt_bind_vma; ppgtt->debug_dump = gen8_dump_ppgtt; -if (USES_FULL_48BIT_PPGTT (ppgtt->base.dev)) { +if (address_space_mode ==48 ) { ret =setup_px (ppgtt->base.dev, &ppgtt->pml4);if (ret) goto free_scratch;
@@ -1545,6 +1551,8 @@ static int gen8_ppgtt_init(struct i915_hw_ppgtt *ppgtt) } } + ppgtt->address_space_mode = address_space_mode; +if (intel_vgpu_active (ppgtt->base.dev))gen8_ppgtt_notify_vgt (ppgtt, true);
@@ -2112,14 +2120,15 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt)return 0 ; } -static int __hw_ppgtt_init (struct drm_device *dev,struct i915_hw_ppgtt *ppgtt) +static int __hw_ppgtt_init (struct drm_device *dev, +struct i915_hw_ppgtt *ppgtt,int address_space_mode) { ppgtt->base.dev = dev;if (INTEL_INFO (dev)->gen <8 )return gen6_ppgtt_init (ppgtt);else -return gen8_ppgtt_init (ppgtt); +return gen8_ppgtt_init (ppgtt, address_space_mode); } static void i915_address_space_init(struct i915_address_space *vm,
@@ -2156,7 +2165,7 @@ int i915_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt)struct drm_i915_private *dev_priv = dev->dev_private;int ret =0 ; - ret =__hw_ppgtt_init (dev, ppgtt); + ret =__hw_ppgtt_init (dev, ppgtt,USES_FULL_48BIT_PPGTT (dev) ?48 :32 );if (ret ==0 ) {kref_init (&ppgtt->ref);i915_address_space_init (&ppgtt->base, dev_priv);
@@ -2777,7 +2786,7 @@ static int i915_gem_setup_global_gtt(struct drm_device *dev,if (!ppgtt)return -ENOMEM ; - ret =__hw_ppgtt_init (dev, ppgtt); + ret =__hw_ppgtt_init (dev, ppgtt,32 );if (ret) { ppgtt->base.cleanup (&ppgtt->base);kfree (ppgtt);
drivers/gpu/drm/i915/i915_gem_gtt.h +3 -0
@@ -110,6 +110,7 @@ typedef uint64_t gen8_ppgtt_pml4e_t;#define I915_PDPES_PER_PDP (dev) (USES_FULL_48BIT_PPGTT(dev) ?\ GEN8_PML4ES_PER_PML4 : GEN8_LEGACY_PDPES) +#define IS_48BIT_PPGTT (ppgtt) ((ppgtt) && ((ppgtt)->address_space_mode == 48))#define PPAT_UNCACHED_INDEX (_PAGE_PWT | _PAGE_PCD)#define PPAT_CACHED_PDE_INDEX 0/* WB LLC */
@@ -372,6 +373,8 @@ struct i915_hw_ppgtt {struct i915_page_directory pd;/* GEN6-7 */ }; +int address_space_mode; +struct drm_i915_file_private *file_priv;gen6_pte_t __iomem *pd_addr;
drivers/gpu/drm/i915/intel_lrc.c +3 -3
@@ -395,7 +395,7 @@ static int execlists_update_context(struct drm_i915_gem_request *rq) reg_state[CTX_RING_TAIL +1 ] = rq->tail; -if (ppgtt && !USES_FULL_48BIT_PPGTT (ppgtt->base.dev)) { +if (ppgtt && !IS_48BIT_PPGTT (ppgtt)) {/* True 32b PPGTT with dynamic page allocation: update PDP * registers and point the unallocated PDPs to scratch page. * PML4 is allocated during ppgtt init, so this is not needed
@@ -1674,7 +1674,7 @@ static int gen8_emit_bb_start(struct drm_i915_gem_request *req,* not needed in 48-bit.*/ if (req->ctx->ppgtt && (intel_ring_flag (req->ring) & req->ctx->ppgtt->pd_dirty_rings)) { -if (!USES_FULL_48BIT_PPGTT (req->i915) && +if (!IS_48BIT_PPGTT (req->ctx->ppgtt) && !intel_vgpu_active (req->i915->dev)) { ret =intel_logical_ring_emit_pdps (req);if (ret)
@@ -2408,7 +2408,7 @@ populate_lr_context(struct intel_context *ctx, struct drm_i915_gem_object *ctx_oASSIGN_CTX_REG (reg_state,CTX_PDP0_UDW ,GEN8_RING_PDP_UDW (ring,0 ),0 );ASSIGN_CTX_REG (reg_state,CTX_PDP0_LDW ,GEN8_RING_PDP_LDW (ring,0 ),0 ); -if (USES_FULL_48BIT_PPGTT (ppgtt->base.dev)) { +if (IS_48BIT_PPGTT (ppgtt)) {/* 64b PPGTT (48bit canonical) * PDP0_DESCRIPTOR contains the base address to PML4 and * other PDP Descriptors are ignored.
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v3 9/15 drm/i915: generate address mode bit from PPGTT instance
In reply to Zhi WangAfter the per-PPGTT address mode gets support, the LRC submission should generate the address mode bit from PPGTT instance, instead of the hard-coded system configuration.
--- drivers/gpu/drm/i915/intel_lrc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +3 -3
@@ -213,7 +213,7 @@ enum {LEGACY_64B_CONTEXT };#define GEN8_CTX_ADDRESSING_MODE_SHIFT 3 -#define GEN8_CTX_ADDRESSING_MODE (dev) (USES_FULL_48BIT_PPGTT(dev) ?\ +#define GEN8_CTX_ADDRESSING_MODE (ppgtt) (IS_48BIT_PPGTT(ppgtt) ? \ LEGACY_64B_CONTEXT :\ LEGACY_32B_CONTEXT)enum {
@@ -274,8 +274,6 @@ logical_ring_init_platform_invariants(struct intel_engine_cs *ring) (ring->id ==VCS || ring->id ==VCS2 ); ring->ctx_desc_template =GEN8_CTX_VALID ; - ring->ctx_desc_template |=GEN8_CTX_ADDRESSING_MODE (dev) << -GEN8_CTX_ADDRESSING_MODE_SHIFT ;if (IS_GEN8 (dev)) ring->ctx_desc_template |=GEN8_CTX_L3LLC_COHERENT ; ring->ctx_desc_template |=GEN8_CTX_PRIVILEGE ;
@@ -318,6 +316,8 @@ intel_lr_context_descriptor_update(struct intel_context *ctx,LRC_PPHWSP_PN *PAGE_SIZE ; desc = ring->ctx_desc_template;/* bits 0-11 */ + desc |=GEN8_CTX_ADDRESSING_MODE (ctx->ppgtt) <</* bits 3-4 */ +GEN8_CTX_ADDRESSING_MODE_SHIFT ; desc |= lrca;/* bits 12-31 */ desc |= (lrca >>PAGE_SHIFT ) <<GEN8_CTX_ID_SHIFT ;/* bits 32-51 */
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v3 10/15 drm/i915: update PDPs by condition when submit the LRC context
In reply to Zhi WangPreviously the PDPs inside the ring context will be updated
- When populating a LRC context
- Before submitting a LRC context (only for 32 bit PPGTT, as the amount of used PDPs may be changed during PPGTT page table grow)
Under GVT-g, each VM owns a GVT context used as the shadow context. When guest submits a context, GVT-g will load guest context into the GVT context, and submit this context to i915 GEM submission system.
So this GVT context could be used by different guest context, and the PPGTT root pointer in guest contexts might be different as well, if guest is using full PPGTT mode.
In current i915, the root pointer in a LRC context will only be updated during the LRC context creation.
This patch postpones the root pointer upgrade to the time of submission, which will give GVT-g a chance to reload a new PPGTT page table root pointer into an existing GVT context.
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_lrc.c | 54 +++++++++++++++++++--------------------- 2 files changed, 27 insertions(+), 28 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -891,6 +891,7 @@ struct intel_context {struct i915_vma *lrc_vma;u64 lrc_desc;uint32_t *lrc_reg_state; +bool root_pointer_dirty; } engine[I915_NUM_RINGS ];struct list_head link;
drivers/gpu/drm/i915/intel_lrc.c +26 -28
93 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [RFCv3 10/15] drm/i915: update PDPs by condition when submit the LRC context
Quoted 14 lines · Zhi Wang
Previously the PDPs inside the ring context will be updated
- When populating a LRC context
- Before submitting a LRC context (only for 32 bit PPGTT, as the amount of used PDPs may be changed during PPGTT page table grow)Under GVT-g, each VM owns a GVT context used as the shadow context. When guest submits a context, GVT-g will load guest context into the GVT context, and submit this context to i915 GEM submission system.
So this GVT context could be used by different guest context, and the PPGTT root pointer in guest contexts might be different as well, if guest is using full PPGTT mode.
Quoted 6 lines
In current i915, the root pointer in a LRC context will only be updated during the LRC context creation.
This patch postpones the root pointer upgrade to the time of submission, which will give GVT-g a chance to reload a new PPGTT page table root pointer into an existing GVT context.
Not explained is why you cannot use the existing dirty flags. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [RFCv3 10/15] drm/i915: update PDPs by condition when submit the LRC context
OK. I will see. :) Thanks for the comments.
-----Original Message-----
From: Chris Wilson [mailto:[email protected]]
Sent: Friday, March 11, 2016 7:28 PM
To: Wang, Zhi A
Cc: [email protected]; [email protected]; Tian, Kevin; Lv, Zhiyuan; Niu, Bing; Song, Jike; [email protected]; Cowperthwaite, David J; [email protected]
Subject: Re: [RFCv3 10/15] drm/i915: update PDPs by condition when submit the LRC context
Quoted 14 lines · Zhi Wang
Previously the PDPs inside the ring context will be updated
- When populating a LRC context
- Before submitting a LRC context (only for 32 bit PPGTT, as the amount of used PDPs may be changed during PPGTT page table grow)Under GVT-g, each VM owns a GVT context used as the shadow context. When guest submits a context, GVT-g will load guest context into the GVT context, and submit this context to i915 GEM submission system.
So this GVT context could be used by different guest context, and the PPGTT root pointer in guest contexts might be different as well, if guest is using full PPGTT mode.
Quoted 6 lines
In current i915, the root pointer in a LRC context will only be updated during the LRC context creation.
This patch postpones the root pointer upgrade to the time of submission, which will give GVT-g a chance to reload a new PPGTT page table root pointer into an existing GVT context.
Not explained is why you cannot use the existing dirty flags. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [RFCv3 10/15] drm/i915: update PDPs by condition when submit the LRC context
Hi Chris:
Your idea is good. :) We could emit PDP upgrade LRIs like i915
before emit GVT worload under GVT context, then we can reuse the pd_dirty_ring bitmap.
But I have to expose intel_logical_ring_emit_pdps() function for GVT-g. Is it acceptable?
Thanks,
Zhi.
Quoted 27 lines · Zhi A
OK. I will see. :) Thanks for the comments.
-----Original Message-----
From: Chris Wilson [mailto:[email protected]]
Sent: Friday, March 11, 2016 7:28 PM
To: Wang, Zhi A
Cc: [email protected]; [email protected]; Tian, Kevin; Lv, Zhiyuan; Niu, Bing; Song, Jike; [email protected]; Cowperthwaite, David J; [email protected]
Subject: Re: [RFCv3 10/15] drm/i915: update PDPs by condition when submit the LRC contextQuoted 17 lines · Zhi Wang
Previously the PDPs inside the ring context will be updated
- When populating a LRC context
- Before submitting a LRC context (only for 32 bit PPGTT, as the amount of used PDPs may be changed during PPGTT page table grow)Under GVT-g, each VM owns a GVT context used as the shadow context. When guest submits a context, GVT-g will load guest context into the GVT context, and submit this context to i915 GEM submission system.
So this GVT context could be used by different guest context, and the PPGTT root pointer in guest contexts might be different as well, if guest is using full PPGTT mode.
In current i915, the root pointer in a LRC context will only be updated during the LRC context creation.
Quoted 7 lines
Quoted 3 lines
This patch postpones the root pointer upgrade to the time of submission, which will give GVT-g a chance to reload a new PPGTT page table root pointer into an existing GVT context.
Not explained is why you cannot use the existing dirty flags. -Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v3 11/15 drm/i915: Introduce execlist context status change notification
In reply to Zhi WangThis patch introduces an approach to track the execlist context status change.
GVT-g uses GVT context as the "shadow context". The content inside GVT context will be copied back to guest after the context is idle. So GVT-g has to know the status of the execlist context.
This function is configurable in the context creation service. Currently, Only GVT-g will create the "status-change-notification" enabled GEM context.
--- drivers/gpu/drm/i915/i915_drv.h | 2 ++ drivers/gpu/drm/i915/intel_lrc.c | 28 ++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_lrc.h | 6 ++++++ 3 files changed, 36 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -892,6 +892,8 @@ struct intel_context {u64 lrc_desc;uint32_t *lrc_reg_state;bool root_pointer_dirty; +bool need_status_change_notification; +struct atomic_notifier_head status_notifier_head; } engine[I915_NUM_RINGS ];struct list_head link;
drivers/gpu/drm/i915/intel_lrc.c +28 -0
@@ -439,6 +439,18 @@ static void execlists_submit_requests(struct drm_i915_gem_request *rq0,execlists_elsp_write (rq0, rq1); } +static inline void execlists_context_status_change ( +struct intel_context *ctx, +struct intel_engine_cs *ring, +unsigned long status) +{ +if (!ctx->engine[ring->id].need_status_change_notification) +return ; + +atomic_notifier_call_chain (&ctx->engine[ring->id].status_notifier_head, + status,NULL ); +} +static void execlists_context_unqueue (struct intel_engine_cs *ring) {struct drm_i915_gem_request *req0 =NULL , *req1 =NULL ;
@@ -495,6 +507,13 @@ static void execlists_context_unqueue(struct intel_engine_cs *ring)WARN_ON (req1 && req1->elsp_submitted); +execlists_context_status_change (req0->ctx, ring,CONTEXT_SCHEDULE_IN ); + +if (req1) { +execlists_context_status_change (req1->ctx, + ring,CONTEXT_SCHEDULE_IN ); + } +execlists_submit_requests (req0, req1); }
@@ -515,6 +534,8 @@ static bool execlists_check_remove_request(struct intel_engine_cs *ring, "Never submitted head request\n");if (--head_req->elsp_submitted <=0 ) { +execlists_context_status_change (head_req->ctx, + ring,CONTEXT_SCHEDULE_OUT );list_move_tail (&head_req->execlist_link, &ring->execlist_retired_req_list);return true;
@@ -2590,6 +2611,13 @@ int __intel_lr_context_deferred_alloc(struct intel_context *ctx, }i915_add_request_no_flush (req); } + +if (params->ctx_needs_status_change_notification) { + ctx->engine[ring->id].need_status_change_notification = true; +ATOMIC_INIT_NOTIFIER_HEAD ( + &ctx->engine[ring->id].status_notifier_head); + } +return 0 ; error_ringbuf:
drivers/gpu/drm/i915/intel_lrc.h +6 -0
@@ -54,6 +54,11 @@#define GEN8_CSB_READ_PTR (csb_status) \ (((csb_status) & GEN8_CSB_READ_PTR_MASK) >> 8) +enum { +CONTEXT_SCHEDULE_IN =0 , +CONTEXT_SCHEDULE_OUT , +}; +/* Logical Rings */ int intel_logical_ring_alloc_request_extras (struct drm_i915_gem_request *request);int intel_logical_ring_reserve_space (struct drm_i915_gem_request *request);
@@ -101,6 +106,7 @@ struct intel_lr_context_alloc_params {struct intel_engine_cs *ring;u32 ringbuffer_size;bool ctx_needs_init; +bool ctx_needs_status_change_notification; };void intel_lr_context_free (struct intel_context *ctx);
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [RFCv3 11/15] drm/i915: Introduce execlist context status change notification
Quoted 10 lines · Zhi Wang
This patch introduces an approach to track the execlist context status change.
GVT-g uses GVT context as the "shadow context". The content inside GVT context will be copied back to guest after the context is idle. So GVT-g has to know the status of the execlist context.
This function is configurable in the context creation service. Currently, Only GVT-g will create the "status-change-notification" enabled GEM context.
Nope. Please hook into the lower-frequency idle mechanism then. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [RFCv3 11/15] drm/i915: Introduce execlist context status change notification
Hi Chirs:
Could you elaborate your idea here? :) As we have to know the status change of the LRC context, not only the request to copy the content back to guest (There will be a small window between a request is finished and the context is switched out). We tried i915_wait_request() before, looks not help... And it seems only CSB change will show the context is really idle.
-----Original Message-----
From: Chris Wilson [mailto:[email protected]]
Sent: Friday, March 11, 2016 7:28 PM
To: Wang, Zhi A
Cc: [email protected]; [email protected]; Tian, Kevin; Lv, Zhiyuan; Niu, Bing; Song, Jike; [email protected]; Cowperthwaite, David J; [email protected]
Subject: Re: [RFCv3 11/15] drm/i915: Introduce execlist context status change notification
Quoted 10 lines · Zhi Wang
This patch introduces an approach to track the execlist context status change.
GVT-g uses GVT context as the "shadow context". The content inside GVT context will be copied back to guest after the context is idle. So GVT-g has to know the status of the execlist context.
This function is configurable in the context creation service. Currently, Only GVT-g will create the "status-change-notification" enabled GEM context.
Nope. Please hook into the lower-frequency idle mechanism then. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v3 12/15 drm/i915: Support context single submission
In reply to Zhi WangThis patch introduces the support of context signle submission. As GVT context may come from different guests, which requires different configuration of render registers. It can't be combined in a dual ELSP submission combo.
We make this function as a context feature in context creation service. Only GVT-g will create this kinds of GEM context currently.
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_lrc.c | 10 +++++++++- drivers/gpu/drm/i915/intel_lrc.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -895,6 +895,7 @@ struct intel_context {bool need_status_change_notification;struct atomic_notifier_head status_notifier_head; } engine[I915_NUM_RINGS ]; +bool single_submission;struct list_head link; };
drivers/gpu/drm/i915/intel_lrc.c +9 -1
@@ -472,6 +472,9 @@ static void execlists_context_unqueue(struct intel_engine_cs *ring) execlist_link) {if (!req0) { req0 = cursor; +/* req0 ctx requires single submission, stop picking */ +if (req0->ctx->single_submission) +break ; }else if (req0->ctx == cursor->ctx) {/* Same ctx: ignore first request, as second request * will update tail past first request's workload */
@@ -480,7 +483,12 @@ static void execlists_context_unqueue(struct intel_engine_cs *ring) &ring->execlist_retired_req_list); req0 = cursor; }else { - req1 = cursor; +/* +* req0 ctx doesn't require single submission, but +* next req ctx requires, stop picking req1 +*/ +if (!cursor->ctx->single_submission) + req1 = cursor;break ; } }
drivers/gpu/drm/i915/intel_lrc.h +1 -0
@@ -107,6 +107,7 @@ struct intel_lr_context_alloc_params {u32 ringbuffer_size;bool ctx_needs_init;bool ctx_needs_status_change_notification; +bool ctx_needs_single_submission; };void intel_lr_context_free (struct intel_context *ctx);
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [RFCv3 12/15] drm/i915: Support context single submission
Quoted 4 lines · Zhi Wang
This patch introduces the support of context signle submission. As GVT context may come from different guests, which requires different configuration of render registers. It can't be combined in a dual ELSP submission combo.
That sounds wrong since the register are part of the context. I presume what you mean is that you cannot combine requests from the same GVT context but different guests.
Quoted 55 lines
We make this function as a context feature in context creation service. Only GVT-g will create this kinds of GEM context currently.
Signed-off-by Zhi Wang <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_lrc.c | 10 +++++++++- drivers/gpu/drm/i915/intel_lrc.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -895,6 +895,7 @@ struct intel_context {bool need_status_change_notification;struct atomic_notifier_head status_notifier_head; } engine[I915_NUM_RINGS ]; +bool single_submission;struct list_head link; };drivers/gpu/drm/i915/intel_lrc.c +9
-1@@ -472,6 +472,9 @@ static void execlists_context_unqueue(struct intel_engine_cs *ring) execlist_link) {if (!req0) { req0 = cursor; +/* req0 ctx requires single submission, stop picking */ +if (req0->ctx->single_submission) +break ; }else if (req0->ctx == cursor->ctx) {/* Same ctx: ignore first request, as second request * will update tail past first request's workload */ @@ -480,7 +483,12 @@ static void execlists_context_unqueue(struct intel_engine_cs *ring) &ring->execlist_retired_req_list); req0 = cursor; }else { - req1 = cursor; +/* +* req0 ctx doesn't require single submission, but +* next req ctx requires, stop picking req1 +*/ +if (!cursor->ctx->single_submission) + req1 = cursor;break ; } }drivers/gpu/drm/i915/intel_lrc.h +0
-0
drivers/gpu/drm/i915/intel_lrc.h struct intel_lr_context_alloc_params { · line 110
Quoted 4 lines
drivers/gpu/drm/i915/intel_lrc.h +1
-0@@ -107,6 +107,7 @@ struct intel_lr_context_alloc_params {u32 ringbuffer_size;bool ctx_needs_init;bool ctx_needs_status_change_notification; +bool ctx_needs_single_submission;
Random garbage.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [RFCv3 12/15] drm/i915: Support context single submission
Hi Chris:
We found that some guest would configure the render MMIOs via MMIO write, not like i915 which issues a lot of LRIs and configure the render mmio by itself(If they initialize their context like what i915 does, that would be nice..).
Here is the scenario, guest configures render MMIOs via MMIO writes(GVT-g will store these values into virtual registers, as HW might be being used by someone else) and then guest submits a restore-inhibit LRC context. It assume currently the render MMIOs have been configured as what it wishes and these MMIO values should be saved into the context...
So we have to reload the render MMIOs to HW for them before the context is submitted to HW by i915 GEM submission...
-----Original Message-----
From: Chris Wilson [mailto:[email protected]]
Sent: Friday, March 11, 2016 7:26 PM
To: Wang, Zhi A
Cc: [email protected]; [email protected]; Tian, Kevin; Lv, Zhiyuan; Niu, Bing; Song, Jike; [email protected]; Cowperthwaite, David J; [email protected]
Subject: Re: [RFCv3 12/15] drm/i915: Support context single submission
Quoted 4 lines · Zhi Wang
This patch introduces the support of context signle submission. As GVT context may come from different guests, which requires different configuration of render registers. It can't be combined in a dual ELSP submission combo.
That sounds wrong since the register are part of the context. I presume what you mean is that you cannot combine requests from the same GVT context but different guests.
Quoted 55 lines
We make this function as a context feature in context creation service. Only GVT-g will create this kinds of GEM context currently.
Signed-off-by Zhi Wang <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_lrc.c | 10 +++++++++- drivers/gpu/drm/i915/intel_lrc.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -895,6 +895,7 @@ struct intel_context {bool need_status_change_notification;struct atomic_notifier_head status_notifier_head; } engine[I915_NUM_RINGS ]; +bool single_submission;struct list_head link; };drivers/gpu/drm/i915/intel_lrc.c +9
-1@@ -472,6 +472,9 @@ static void execlists_context_unqueue(struct intel_engine_cs *ring) execlist_link) {if (!req0) { req0 = cursor; +/* req0 ctx requires single submission, stop picking */ +if (req0->ctx->single_submission) +break ; }else if (req0->ctx == cursor->ctx) {/* Same ctx: ignore first request, as second request * will update tail past first request's workload */ @@ -480,7 +483,12 @@ static void execlists_context_unqueue(struct intel_engine_cs *ring) &ring->execlist_retired_req_list); req0 = cursor; }else { - req1 = cursor; +/* +* req0 ctx doesn't require single submission, but +* next req ctx requires, stop picking req1 +*/ +if (!cursor->ctx->single_submission) + req1 = cursor;break ; } }drivers/gpu/drm/i915/intel_lrc.h +0
-0
drivers/gpu/drm/i915/intel_lrc.h struct intel_lr_context_alloc_params { · line 110
Quoted 4 lines
drivers/gpu/drm/i915/intel_lrc.h +1
-0@@ -107,6 +107,7 @@ struct intel_lr_context_alloc_params {u32 ringbuffer_size;bool ctx_needs_init;bool ctx_needs_status_change_notification; +bool ctx_needs_single_submission;
Random garbage.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v3 13/15 drm/i915: Introduce GVT context creation API
In reply to Zhi WangGVT workload scheduler needs special host LRC contexts, the so called "shadow LRC context" to submit guest workload to host i915. During the guest workload submission, GVT fills the shadow LRC context with the content of guest LRC context: engine context is copied without changes, ring context is mostly owned by host i915.
The GVT-g workload scheduler flow:
+-----------+ +-----------+
| GVT Guest | | GVT Guest |
+-+-----^---+ +-+-----^---+
| | | |
| | GVT-g | | GVT-g
vELSP write| | emulates vELSP write| | emulates
| | Execlist/CSB | | Execlist/CSB
| | Status | | Status
| | | |
+------v-----+-------------------------v-----+---------+
| GVT Virtual Execlist Submission |
+------+-------------------------------+---------------+
| |
| Per-VM/Ring Workoad Q | Per-VM/Ring Workload Q
+---------------------+--+ +------------------------+
+---v--------+ ^ +---v--------+
|GVT Workload|... | |GVT Workload|...
+------------+ | +------------+
|
| Pick Workload from Q
+--------------------+---------------------------------+
| GVT Workload Scheduler |
+--------------------+---------------------------------+
| * Shadow guest LRC context
+------v------+ * Shadow guest ring buffer
| GVT Context | * Scan/Patch guest RB instructions
+------+------+
| v
Host i915 GEM Submission
v2:
Mostly based on Daniel's idea. Call the refactored core logic of GEM context creation service and LRC context creation service to create the GVT context.
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_gem_context.c | 52 +++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -3270,6 +3270,7 @@ i915_gem_context_get(struct drm_i915_file_private *file_priv, u32 id);void i915_gem_context_free (struct kref *ctx_ref);struct drm_i915_gem_object *i915_gem_alloc_context_obj (struct drm_device *dev,size_t size); +struct intel_context *i915_gem_create_gvt_context (struct drm_device *dev);static inline void i915_gem_context_reference (struct intel_context *ctx) {kref_get (&ctx->ref);
drivers/gpu/drm/i915/i915_gem_context.c +52 -0
58 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v3 14/15 drm/i915: factor out and expose i915_steal_fence()
In reply to Zhi WangFactor out and expose fence stealing functionality for GVT-g. GVT-g will use i915_find_fence_reg() to find a free/unpin fence register and use i915_steal_fence() to steal it.
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_gem_fence.c | 36 ++++++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -3247,6 +3247,7 @@ i915_gem_object_ggtt_unpin(struct drm_i915_gem_object *obj)/* i915_gem_fence.c */ int __must_check i915_gem_object_get_fence (struct drm_i915_gem_object *obj);int __must_check i915_gem_object_put_fence (struct drm_i915_gem_object *obj); +int i915_steal_fence (struct drm_i915_fence_reg *reg);bool i915_gem_object_pin_fence (struct drm_i915_gem_object *obj);void i915_gem_object_unpin_fence (struct drm_i915_gem_object *obj);
drivers/gpu/drm/i915/i915_gem_fence.c +27 -9
@@ -346,6 +346,30 @@ deadlock: }/** +* i915_steal_fence - steal a fence from a GEM object +* @reg: the fence register to be stolen +* +* Returns: +* +* 0 on success, negative error code on failure. +*/ +int i915_steal_fence (struct drm_i915_fence_reg *reg) +{ +int ret; + +if (reg->obj) { +struct drm_i915_gem_object *old = reg->obj; + + ret =i915_gem_object_wait_fence (old); +if (ret) +return ret; + +i915_gem_object_fence_lost (old); + } +return 0 ; +} + +/** * i915_gem_object_get_fence - set up fencing for an object * @obj: object to map through a fence reg *
@@ -397,15 +421,9 @@ i915_gem_object_get_fence(struct drm_i915_gem_object *obj)if (IS_ERR (reg))return PTR_ERR (reg); -if (reg->obj) { -struct drm_i915_gem_object *old = reg->obj; - - ret =i915_gem_object_wait_fence (old); -if (ret) -return ret; - -i915_gem_object_fence_lost (old); - } + ret =i915_steal_fence (reg); +if (ret) +return ret; }else return 0 ;
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [RFCv3 14/15] drm/i915: factor out and expose i915_steal_fence()
Quoted 31 lines · Zhi Wang
Factor out and expose fence stealing functionality for GVT-g. GVT-g will use
i915_find_fence_reg()to find a free/unpin fence register and usei915_steal_fence()to steal it.Signed-off-by Zhi Wang <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_gem_fence.c | 36 ++++++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 9 deletions(-)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -3247,6 +3247,7 @@ i915_gem_object_ggtt_unpin(struct drm_i915_gem_object *obj)/* i915_gem_fence.c */ int __must_check i915_gem_object_get_fence (struct drm_i915_gem_object *obj);int __must_check i915_gem_object_put_fence (struct drm_i915_gem_object *obj); +int i915_steal_fence (struct drm_i915_fence_reg *reg);bool i915_gem_object_pin_fence (struct drm_i915_gem_object *obj);void i915_gem_object_unpin_fence (struct drm_i915_gem_object *obj);drivers/gpu/drm/i915/i915_gem_fence.c +1
-0@@ -346,6 +346,30 @@ deadlock: }/** +* i915_steal_fence - steal a fence from a GEM object
drivers/gpu/drm/i915/i915_gem_fence.c deadlock: · line 359
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_fence.c +10
-0+* @reg: the fence register to be stolen +* +* Returns: +* +* 0 on success, negative error code on failure. +*/ +int i915_steal_fence (struct drm_i915_fence_reg *reg) +{ +int ret; +
No, this is not safe.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [RFCv3 14/15] drm/i915: factor out and expose i915_steal_fence()
Hi Chris:
Do you mean I should also check the fence pin count in this API like i915_find_fence_reg, then it will be safe here? :)
-----Original Message-----
From: Chris Wilson [mailto:[email protected]]
Sent: Friday, March 11, 2016 7:22 PM
To: Wang, Zhi A
Cc: [email protected]; [email protected]; Tian, Kevin; Lv, Zhiyuan; Niu, Bing; Song, Jike; [email protected]; Cowperthwaite, David J; [email protected]
Subject: Re: [RFCv3 14/15] drm/i915: factor out and expose i915_steal_fence()
Quoted 31 lines · Zhi Wang
Factor out and expose fence stealing functionality for GVT-g. GVT-g will use
i915_find_fence_reg()to find a free/unpin fence register and usei915_steal_fence()to steal it.Signed-off-by Zhi Wang <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_gem_fence.c | 36 ++++++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 9 deletions(-)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -3247,6 +3247,7 @@ i915_gem_object_ggtt_unpin(struct drm_i915_gem_object *obj)/* i915_gem_fence.c */ int __must_check i915_gem_object_get_fence (struct drm_i915_gem_object *obj);int __must_check i915_gem_object_put_fence (struct drm_i915_gem_object *obj); +int i915_steal_fence (struct drm_i915_fence_reg *reg);bool i915_gem_object_pin_fence (struct drm_i915_gem_object *obj);void i915_gem_object_unpin_fence (struct drm_i915_gem_object *obj);drivers/gpu/drm/i915/i915_gem_fence.c +1
-0@@ -346,6 +346,30 @@ deadlock: }/** +* i915_steal_fence - steal a fence from a GEM object
drivers/gpu/drm/i915/i915_gem_fence.c deadlock: · line 359
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_fence.c +10
-0+* @reg: the fence register to be stolen +* +* Returns: +* +* 0 on success, negative error code on failure. +*/ +int i915_steal_fence (struct drm_i915_fence_reg *reg) +{ +int ret; +
No, this is not safe.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [RFCv3 14/15] drm/i915: factor out and expose i915_steal_fence()
Quoted 2 lines · Zhi A
Hi Chris:
Do you mean I should also check the fence pin count in this API likei915_find_fence_reg, then it will be safe here? :)
Along those lines. I don't like the prospect of exporting this API and without seeing the consumer I cannot advise on a better method. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [RFCv3 14/15] drm/i915: factor out and expose i915_steal_fence()
OK. I see. Previously the fence registers for host is partitioned. For example, host i915 will only take 4 fence registers, others are kept by GVT-g resource allocator for vGPUs. Danile and Kevin, they thought we could use i915 fence stealing functionality to prevent this static partition. So my idea is:
a. When GVT create a guest, it will call i915_find_fence_regs for available physical fence registers. b. Then it will call i915_steal_fence and pin these fence registers for vGPUs.
c. Then unpin them, when a guest is destroyed.
So I expose these two APIs. Do you have any better ideas to share? :)
And thanks for the comments. :)
-----Original Message-----
From: Chris Wilson [mailto:[email protected]]
Sent: Friday, March 11, 2016 8:43 PM
To: Wang, Zhi A
Cc: [email protected]; [email protected]; Tian, Kevin; Lv, Zhiyuan; Niu, Bing; Song, Jike; [email protected]; Cowperthwaite, David J; [email protected]
Subject: Re: [RFCv3 14/15] drm/i915: factor out and expose i915_steal_fence()
Quoted 2 lines · Zhi A
Hi Chris:
Do you mean I should also check the fence pin count in this API likei915_find_fence_reg, then it will be safe here? :)
Along those lines. I don't like the prospect of exporting this API and without seeing the consumer I cannot advise on a better method. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [RFCv3 14/15] drm/i915: factor out and expose i915_steal_fence()
In reply to Chris WilsonBTW, for better review, I didn't send out the whole GVT-g device model here. Just the patches related to i915... :)
-----Original Message-----
From: Wang, Zhi A
Sent: Friday, March 11, 2016 8:54 PM
To: 'Chris Wilson'
Cc: [email protected]; [email protected]; Tian, Kevin; Lv, Zhiyuan; Niu, Bing; Song, Jike; [email protected]; Cowperthwaite, David J; [email protected]
Subject: RE: [RFCv3 14/15] drm/i915: factor out and expose i915_steal_fence()
OK. I see. Previously the fence registers for host is partitioned. For example, host i915 will only take 4 fence registers, others are kept by GVT-g resource allocator for vGPUs. Danile and Kevin, they thought we could use i915 fence stealing functionality to prevent this static partition. So my idea is:
a. When GVT create a guest, it will call i915_find_fence_regs for available physical fence registers. b. Then it will call i915_steal_fence and pin these fence registers for vGPUs.
c. Then unpin them, when a guest is destroyed.
So I expose these two APIs. Do you have any better ideas to share? :)
And thanks for the comments. :)
-----Original Message-----
From: Chris Wilson [mailto:[email protected]]
Sent: Friday, March 11, 2016 8:43 PM
To: Wang, Zhi A
Cc: [email protected]; [email protected]; Tian, Kevin; Lv, Zhiyuan; Niu, Bing; Song, Jike; [email protected]; Cowperthwaite, David J; [email protected]
Subject: Re: [RFCv3 14/15] drm/i915: factor out and expose i915_steal_fence()
Quoted 2 lines · Zhi A
Hi Chris:
Do you mean I should also check the fence pin count in this API likei915_find_fence_reg, then it will be safe here? :)
Along those lines. I don't like the prospect of exporting this API and without seeing the consumer I cannot advise on a better method. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v3 15/15 drm/i915: expose i915_find_fence_reg()
In reply to Zhi WangExpose i915_find_fence_reg() for GVT-g to allocate the fence registers for vGPUs.
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_gem_fence.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -3248,6 +3248,7 @@ i915_gem_object_ggtt_unpin(struct drm_i915_gem_object *obj)int __must_check i915_gem_object_get_fence (struct drm_i915_gem_object *obj);int __must_check i915_gem_object_put_fence (struct drm_i915_gem_object *obj);int i915_steal_fence (struct drm_i915_fence_reg *reg); +struct drm_i915_fence_reg *i915_find_fence_reg (struct drm_device *dev);bool i915_gem_object_pin_fence (struct drm_i915_gem_object *obj);void i915_gem_object_unpin_fence (struct drm_i915_gem_object *obj);
drivers/gpu/drm/i915/i915_gem_fence.c +9 -1
@@ -308,7 +308,15 @@ i915_gem_object_put_fence(struct drm_i915_gem_object *obj)return 0 ; } -static struct drm_i915_fence_reg * +/** +* i915_find_fence_reg - find a free or unpinned fence register +* @dev: drm device +* +* Returns: +* +* pointer to fence register on success, error code in pointer on failure. +*/ +struct drm_i915_fence_reg *i915_find_fence_reg (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.BAT: failure for Introduce GVT context support
In reply to Zhi Wang== Series Details ==
== Series Details ==
Series: Introduce GVT context support
URL : https://patchwork.freedesktop.org/series/4351/
State : failure
== Summary ==
Series 4351v1 Introduce GVT context support
2016-03-11T10:50:52.806659 http://patchwork.freedesktop.org/api/1.0/series/4351/revisions/1/mbox/
Applying: drm/i915: factor out i915_pvinfo.h
Applying: drm/i915/gvt: Introduce the basic architecture of GVT-g Using index info to reconstruct a base tree...
M drivers/gpu/drm/i915/Kconfig
M drivers/gpu/drm/i915/Makefile
M drivers/gpu/drm/i915/i915_dma.c
M drivers/gpu/drm/i915/i915_drv.h
M drivers/gpu/drm/i915/i915_gem_gtt.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/gpu/drm/i915/i915_gem_gtt.c
Auto-merging drivers/gpu/drm/i915/i915_drv.h
Auto-merging drivers/gpu/drm/i915/i915_dma.c
Auto-merging drivers/gpu/drm/i915/Makefile
Auto-merging drivers/gpu/drm/i915/Kconfig
CONFLICT (content): Merge conflict in drivers/gpu/drm/i915/Kconfig Patch failed at 0002 drm/i915/gvt: Introduce the basic architecture of GVT-g
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx