[v2] drm/i915/gvt: do not reference a virtual address after kunmap

Submitted by Zhao, Yan Y on May 30, 2019, 11:27 a.m.

Details

Message ID 20190530112720.8630-1-yan.y.zhao@intel.com
State New
Headers show
Series "drm/i915/gvt: defer page unmap until after finish referencing it" ( rev: 2 ) in Intel GVT devel

Not browsing as part of any series.

Commit Message

Zhao, Yan Y May 30, 2019, 11:27 a.m.
store the context ctl value into local variable, so as not to reference
a virtual address after kunmap

v2: use local variable to avoid referencing vaddr after kunmap

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

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c
index 353b4d0da6b4..4e44d70fa772 100644
--- a/drivers/gpu/drm/i915/gvt/scheduler.c
+++ b/drivers/gpu/drm/i915/gvt/scheduler.c
@@ -132,6 +132,7 @@  static int populate_shadow_context(struct intel_vgpu_workload *workload)
 	void *dst;
 	unsigned long context_gpa, context_page_num;
 	int i;
+	u32 ctx_ctrl_val;
 
 	page = i915_gem_object_get_page(ctx_obj, LRC_STATE_PN);
 	shadow_ring_context = kmap(page);
@@ -150,6 +151,8 @@  static int populate_shadow_context(struct intel_vgpu_workload *workload)
 	COPY_REG_MASKED(ctx_ctrl);
 	COPY_REG(ctx_timestamp);
 
+	ctx_ctrl_val = shadow_ring_context->ctx_ctrl.val;
+
 	if (ring_id == RCS0) {
 		COPY_REG(bb_per_ctx_ptr);
 		COPY_REG(rcs_indirect_ctx);
@@ -168,7 +171,7 @@  static int populate_shadow_context(struct intel_vgpu_workload *workload)
 	sr_oa_regs(workload, (u32 *)shadow_ring_context, false);
 	kunmap(page);
 
-	if (IS_RESTORE_INHIBIT(shadow_ring_context->ctx_ctrl.val))
+	if (IS_RESTORE_INHIBIT(ctx_ctrl_val))
 		return 0;
 
 	gvt_dbg_sched("ring id %d workload lrca %x", ring_id,