drm/i915/gvt: defer page unmap until after finish referencing it

Submitted by Zhao, Yan Y on May 30, 2019, 8:09 a.m.

Details

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

Not browsing as part of any series.

Commit Message

Zhao, Yan Y May 30, 2019, 8:09 a.m.
It is better to move kunmap to after referencing the virtual address

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

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..8f3ba49b06f5 100644
--- a/drivers/gpu/drm/i915/gvt/scheduler.c
+++ b/drivers/gpu/drm/i915/gvt/scheduler.c
@@ -166,10 +166,13 @@  static int populate_shadow_context(struct intel_vgpu_workload *workload)
 			I915_GTT_PAGE_SIZE - sizeof(*shadow_ring_context));
 
 	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(shadow_ring_context->ctx_ctrl.val)) {
+		kunmap(page);
 		return 0;
+	}
+
+	kunmap(page);
 
 	gvt_dbg_sched("ring id %d workload lrca %x", ring_id,
 			workload->ctx_desc.lrca);