[v2] drm/i915/gvt: support MI_SEMAPHORE_WAIT

Submitted by Zhao, Yan Y on March 25, 2019, 7:04 a.m.

Details

Message ID 20190325070411.16113-1-yan.y.zhao@intel.com
State New
Headers show
Series "drm/i915/gvt: support MI_SEMAPHORE_WAIT" ( rev: 2 ) in Intel GVT devel

Not browsing as part of any series.

Commit Message

Zhao, Yan Y March 25, 2019, 7:04 a.m.
recent i915 driver uses MI_SEMAPHORE_WAIT to sync requests.
GVT-g should add support for this command, otherwise i915 guest would fail
in cmd parser and cause guest VM failure

v2: refine commit message (zhenyu wang)

Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
---
 drivers/gpu/drm/i915/gvt/cmd_parser.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/i915/gvt/cmd_parser.c b/drivers/gpu/drm/i915/gvt/cmd_parser.c
index a16e527e9f02..e98f0a0d3083 100644
--- a/drivers/gpu/drm/i915/gvt/cmd_parser.c
+++ b/drivers/gpu/drm/i915/gvt/cmd_parser.c
@@ -1538,7 +1538,30 @@  static int cmd_handler_mi_store_data_imm(struct parser_exec_state *s)
 
 static int cmd_handler_mi_semaphore_wait(struct parser_exec_state *s)
 {
-	return unexpected_cmd(s);
+	unsigned long gma, gma_high;
+	int ret = 0;
+	int cmd_len = cmd_length(s);
+	struct intel_vgpu *vgpu = s->vgpu;
+	int gma_len = sizeof(u32);
+
+	if (cmd_len != 4 && cmd_len != 5) {
+		gvt_vgpu_err("Illegal cmd length %d\n", cmd_len);
+		return -EINVAL;
+	}
+
+	/* ppgtt is always safe */
+	if (!(cmd_val(s, 0) & (1 << 22)))
+		return ret;
+
+	gma = cmd_val(s, 2) & GENMASK(31, 0);
+	if (cmd_len == 5) {
+		gma_high = cmd_val(s, 3) & GENMASK(31, 0);
+		gma = (gma_high << 32) | gma;
+		gma_len = sizeof(u64);
+	}
+	ret = cmd_address_audit(s, gma, gma_len, false);
+	return ret;
+
 }
 
 static int cmd_handler_mi_report_perf_count(struct parser_exec_state *s)