Skip to contentSkip to conversation

enable virtual HWSP in GVT-g

PATCH New Weinan Li 2 participants 4 messages Oct 12, 2017

Subsystems (3)
lore
Share & tools
lore

Weinan Li

author
#0 lore raw

v3 cover enable virtual HWSP in GVT-g

v2 : clean merge confict

v3 :
remove unnecessary comments
add address audit in HWSP address update

Weinan Li (2):
drm/i915/gvt: update CSB and CSB write pointer in virtual HWSP drm/i915: enable to read CSB and CSB write pointer from HWSP in GVT-g
VM

 drivers/gpu/drm/i915/gvt/execlist.c    | 17 +++++++++++++
 drivers/gpu/drm/i915/gvt/gvt.h         |  1 +
 drivers/gpu/drm/i915/gvt/handlers.c    | 45 +++++++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/gvt/vgpu.c        |  8 ++++++
 drivers/gpu/drm/i915/i915_pvinfo.h     |  1 +
 drivers/gpu/drm/i915/i915_vgpu.c       |  5 ++++
 drivers/gpu/drm/i915/i915_vgpu.h       |  1 +
 drivers/gpu/drm/i915/intel_engine_cs.c |  8 +++---
 drivers/gpu/drm/i915/intel_lrc.c       |  1 -
 9 files changed, 81 insertions(+), 6 deletions(-)
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
author
#1 lore raw

PATCH v3 1/2 drm/i915/gvt: update CSB and CSB write pointer in virtual HWSP

The engine provides a mirror of the CSB and CSB write pointer in the HWSP. Read these status from virtual HWSP in VM can reduce CPU utilization while applications have much more short GPU workloads. Here we update the corresponding data in virtual HWSP as it in virtual MMIO.

Before read these status from HWSP in GVT-g VM, please ensure the host support it by checking the BIT(3) of caps in PVINFO.

Virtual HWSP only support GEN8+ platform, since the HWSP MMIO may change follow the platform update, please add the corresponding MMIO emulation when enable new platforms in GVT-g.

v3 : Add address audit in HWSP address update.

Cc Chris Wilson <[email protected]>
---
 drivers/gpu/drm/i915/gvt/execlist.c | 17 ++++++++++++++
 drivers/gpu/drm/i915/gvt/gvt.h      |  1 +
 drivers/gpu/drm/i915/gvt/handlers.c | 45 ++++++++++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/gvt/vgpu.c     |  8 +++++++
 drivers/gpu/drm/i915/i915_pvinfo.h  |  1 +
 5 files changed, 71 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gvt/execlist.c +17 -0
index 5c966ed..7bc7286 100644
@@ -133,6 +133,8 @@ static void emulate_csb_update(struct intel_vgpu_execlist *execlist,
 	struct execlist_context_status_pointer_format ctx_status_ptr;
 	u32 write_pointer;
 	u32 ctx_status_ptr_reg, ctx_status_buf_reg, offset;
+	unsigned long hwsp_gpa;
+	struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv;
 
 	ctx_status_ptr_reg = execlist_ring_mmio(vgpu->gvt, ring_id,
 			_EL_OFFSET_STATUS_PTR);
@@ -158,6 +160,21 @@ static void emulate_csb_update(struct intel_vgpu_execlist *execlist,
 	ctx_status_ptr.write_ptr = write_pointer;
 	vgpu_vreg(vgpu, ctx_status_ptr_reg) = ctx_status_ptr.dw;
 
+	/* Update the CSB and CSB write pointer in HWSP */
+	if (INTEL_INFO(dev_priv)->gen >= 8) {
+		hwsp_gpa = intel_vgpu_gma_to_gpa(vgpu->gtt.ggtt_mm,
+						 vgpu->hws_pga[ring_id]);
+		if (hwsp_gpa != INTEL_GVT_INVALID_ADDR) {
+			intel_gvt_hypervisor_write_gpa(vgpu,
+				hwsp_gpa + I915_HWS_CSB_BUF0_INDEX * 4 +
+				write_pointer * 8,
+				status, 8);
+			intel_gvt_hypervisor_write_gpa(vgpu,
+				hwsp_gpa +
+				intel_hws_csb_write_index(dev_priv) * 4,
+				&write_pointer, 4);
+		}
+	}
 	gvt_dbg_el("vgpu%d: w pointer %u reg %x csb l %x csb h %x\n",
 		vgpu->id, write_pointer, offset, status->ldw, status->udw);
 
drivers/gpu/drm/i915/gvt/gvt.h +1 -0
index f08d194..27e8186 100644
@@ -189,6 +189,7 @@ struct intel_vgpu {
 	struct intel_vgpu_opregion opregion;
 	struct intel_vgpu_display display;
 	struct intel_vgpu_submission submission;
+	u32 hws_pga[I915_NUM_ENGINES];
 
 	struct dentry *debugfs;
 
drivers/gpu/drm/i915/gvt/handlers.c +44 -1

57 lines not on this page · raw message

drivers/gpu/drm/i915/gvt/vgpu.c +8 -0
index 99dbefa..5d180c6 100644
@@ -43,7 +43,15 @@ void populate_pvinfo_page(struct intel_vgpu *vgpu)
 	vgpu_vreg(vgpu, vgtif_reg(version_minor)) = 0;
 	vgpu_vreg(vgpu, vgtif_reg(display_ready)) = 0;
 	vgpu_vreg(vgpu, vgtif_reg(vgt_id)) = vgpu->id;
+
 	vgpu_vreg(vgpu, vgtif_reg(vgt_caps)) = VGT_CAPS_FULL_48BIT_PPGTT;
+	/*
+	 * Add HWSP emulation support after gen8 platform, VM need to check
+	 * this caps to ensure it can read CSB status in HWSP.
+	 */
+	if (INTEL_INFO(vgpu->gvt->dev_priv)->gen >= 8)
+		vgpu_vreg(vgpu, vgtif_reg(vgt_caps)) |= VGT_CAPS_HWSP_EMULATION;
+
 	vgpu_vreg(vgpu, vgtif_reg(avail_rs.mappable_gmadr.base)) =
 		vgpu_aperture_gmadr_base(vgpu);
 	vgpu_vreg(vgpu, vgtif_reg(avail_rs.mappable_gmadr.size)) =
drivers/gpu/drm/i915/i915_pvinfo.h +1 -0
index 0679a58..195203f 100644
@@ -53,6 +53,7 @@ enum vgt_g2v_type {
  * VGT capabilities type
  */
 #define VGT_CAPS_FULL_48BIT_PPGTT	BIT(2)
+#define VGT_CAPS_HWSP_EMULATION		BIT(3)
 
 struct vgt_if {
 	u64 magic;		/* VGT_MAGIC */
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
author
#2 lore raw

PATCH v3 2/2 drm/i915: enable to read CSB and CSB write pointer from HWSP in GVT-g VM

In reply to Weinan Li

Let GVT-g VM read the CSB and CSB write pointer from virtual HWSP, not all the host support this feature, need to check the BIT(3) of caps in PVINFO.

v3 : Remove unnecessary comments.

Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/i915_vgpu.c       | 5 +++++
 drivers/gpu/drm/i915/i915_vgpu.h       | 1 +
 drivers/gpu/drm/i915/intel_engine_cs.c | 8 ++++----
 drivers/gpu/drm/i915/intel_lrc.c       | 1 -
 4 files changed, 10 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_vgpu.c +5 -0
index 5fe9f3f..6f713c5 100644
@@ -86,6 +86,11 @@ bool intel_vgpu_has_full_48bit_ppgtt(struct drm_i915_private *dev_priv)
 	return dev_priv->vgpu.caps & VGT_CAPS_FULL_48BIT_PPGTT;
 }
 
+bool intel_vgpu_has_hwsp_emulation(struct drm_i915_private *dev_priv)
+{
+	return dev_priv->vgpu.caps & VGT_CAPS_HWSP_EMULATION;
+}
+
 struct _balloon_info_ {
 	/*
 	 * There are up to 2 regions per mappable/unmappable graphic
drivers/gpu/drm/i915/i915_vgpu.h +1 -0
index b72bd29..cec0ec1 100644
@@ -29,6 +29,7 @@
 void i915_check_vgpu(struct drm_i915_private *dev_priv);
 
 bool intel_vgpu_has_full_48bit_ppgtt(struct drm_i915_private *dev_priv);
+bool intel_vgpu_has_hwsp_emulation(struct drm_i915_private *dev_priv);
 
 int intel_vgt_balloon(struct drm_i915_private *dev_priv);
 void intel_vgt_deballoon(struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/intel_engine_cs.c +4 -4
index 807a7aa..93478c2 100644
@@ -23,6 +23,7 @@
  */
 
 #include "i915_drv.h"
+#include "i915_vgpu.h"
 #include "intel_ringbuffer.h"
 #include "intel_lrc.h"
 
@@ -384,10 +385,6 @@ static void intel_engine_init_timeline(struct intel_engine_cs *engine)
 
 static bool csb_force_mmio(struct drm_i915_private *i915)
 {
-	/* GVT emulation depends upon intercepting CSB mmio */
-	if (intel_vgpu_active(i915))
-		return true;
-
 	/*
 	 * IOMMU adds unpredictable latency causing the CSB write (from the
 	 * GPU into the HWSP) to only be visible some time after the interrupt
@@ -396,6 +393,9 @@ static bool csb_force_mmio(struct drm_i915_private *i915)
 	if (intel_vtd_active())
 		return true;
 
+	if (intel_vgpu_active(i915) && !intel_vgpu_has_hwsp_emulation(i915))
+		return true;
+
 	return false;
 }
 
drivers/gpu/drm/i915/intel_lrc.c +0 -1
index 721432d..3c91971 100644
@@ -793,7 +793,6 @@ static void intel_lrc_irq_handler(unsigned long data)
 			&engine->status_page.page_addr[I915_HWS_CSB_BUF0_INDEX];
 		unsigned int head, tail;
 
-		/* However GVT emulation depends upon intercepting CSB mmio */
 		if (unlikely(execlists->csb_use_mmio)) {
 			buf = (u32 * __force)
 				(dev_priv->regs + i915_mmio_reg_offset(RING_CONTEXT_STATUS_BUF_LO(engine, 0)));
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

✗ Fi.CI.BAT: failure for enable virtual HWSP in GVT-g (rev2)

In reply to Weinan Li
== Series Details ==

== Series Details ==

Series: enable virtual HWSP in GVT-g (rev2)
URL : https://patchwork.freedesktop.org/series/31217/
State : failure

== Summary ==

Series 31217 revision 2 was fully merged or fully failed: no git log

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx