clear-pkgs-linux-iot-lts2018/0535-drm-i915-gvt-Simply-th...

109 lines
3.5 KiB
Diff

From c0cef17a1ac568ddb4bf59d84875e969389166a4 Mon Sep 17 00:00:00 2001
From: Ping Gao <ping.a.gao@intel.com>
Date: Wed, 6 Sep 2017 16:13:40 +0800
Subject: [PATCH 535/550] drm/i915/gvt: Simply the conformance check
The overall comparison for non-context MMIOs only need once, then
it's enough for conformance check that audit these MMIOs during
runtime to make sure the value written to them are the same with
the host cache. The way could void frequently overall comparion.
Signed-off-by: Ping Gao <ping.a.gao@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Singh, Satyeshwar <satyeshwar.singh@intel.com>
Reviewed-on:
Reviewed-by: He, Min <min.he@intel.com>
Reviewed-by: Jiang, Fei <fei.jiang@intel.com>
Reviewed-by: Dong, Eddie <eddie.dong@intel.com>
Tested-by: Dong, Eddie <eddie.dong@intel.com>
v2: rebase to 4.19, reuse gvt_host_reg() to fix wrong offset
Signed-off-by: Xinyun Liu <xinyun.liu@intel.com>
---
drivers/gpu/drm/i915/gvt/cmd_parser.c | 26 ++++++++++++++++++++++++++
drivers/gpu/drm/i915/gvt/gvt.h | 1 +
drivers/gpu/drm/i915/gvt/mmio.c | 10 ++++++++++
3 files changed, 37 insertions(+)
diff --git a/drivers/gpu/drm/i915/gvt/cmd_parser.c b/drivers/gpu/drm/i915/gvt/cmd_parser.c
index 9115c3dc2fc9..4fa37daf13d6 100644
--- a/drivers/gpu/drm/i915/gvt/cmd_parser.c
+++ b/drivers/gpu/drm/i915/gvt/cmd_parser.c
@@ -966,6 +966,32 @@ static int cmd_handler_lri(struct parser_exec_state *s)
ret |= cmd_reg_handler(s, cmd_reg(s, i), i, "lri");
if (ret)
break;
+
+ if (s->vgpu->entire_nonctxmmio_checked
+ && intel_gvt_mmio_is_non_context(gvt,
+ cmd_reg(s, i))) {
+ int offset = cmd_reg(s, i);
+ int value = cmd_val(s, i + 1);
+
+ if (intel_gvt_mmio_has_mode_mask(gvt, offset)) {
+ u32 mask = value >> 16;
+
+ vgpu_vreg(s->vgpu, offset) =
+ (vgpu_vreg(s->vgpu, offset) & ~mask)
+ | (value & mask);
+ } else {
+ vgpu_vreg(s->vgpu, offset) = value;
+ }
+
+ if (gvt_host_reg(gvt, offset) !=
+ vgpu_vreg(s->vgpu, offset)) {
+
+ gvt_err("vgpu%d unexpected non-context MMIO "
+ "access by cmd 0x%x:0x%x,0x%x\n",
+ s->vgpu->id, offset, value,
+ gvt_host_reg(gvt, offset));
+ }
+ }
}
return ret;
}
diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h
index 882859c20332..7da1e9bad5cc 100644
--- a/drivers/gpu/drm/i915/gvt/gvt.h
+++ b/drivers/gpu/drm/i915/gvt/gvt.h
@@ -239,6 +239,7 @@ struct intel_vgpu {
unsigned long long *cached_guest_entry;
bool ge_cache_enable;
+ bool entire_nonctxmmio_checked;
};
/* validating GM healthy status*/
diff --git a/drivers/gpu/drm/i915/gvt/mmio.c b/drivers/gpu/drm/i915/gvt/mmio.c
index 4cb3f72ab56a..b6a974f55805 100644
--- a/drivers/gpu/drm/i915/gvt/mmio.c
+++ b/drivers/gpu/drm/i915/gvt/mmio.c
@@ -213,6 +213,14 @@ int intel_vgpu_emulate_mmio_write(struct intel_vgpu *vgpu, uint64_t pa,
if (ret < 0)
goto err;
+ if (vgpu->entire_nonctxmmio_checked
+ && intel_gvt_mmio_is_non_context(vgpu->gvt, offset)
+ && vgpu_vreg(vgpu, offset) != gvt_host_reg(gvt, offset)) {
+ gvt_err("vgpu%d unexpected non-context MMIO change at 0x%x:0x%x,0x%x\n",
+ vgpu->id, offset, vgpu_vreg(vgpu, offset),
+ gvt_host_reg(gvt, offset));
+ }
+
intel_gvt_mmio_set_accessed(gvt, offset);
ret = 0;
goto out;
@@ -298,6 +306,8 @@ void intel_vgpu_reset_mmio(struct intel_vgpu *vgpu, bool dmlr)
vgpu_vreg_t(vgpu, HUC_STATUS2) = I915_READ(HUC_STATUS2);
mmio_hw_access_post(dev_priv);
}
+ /* Non-context MMIOs need entire check again if mmio/vgpu reset */
+ vgpu->entire_nonctxmmio_checked = false;
}
/**
--
2.19.1