Skip to content

Commit 8bfa02c

Browse files
yanzhao56zhenyw
authored andcommitted
drm/i915/gvt: only copy the first page for restore inhibit context
if a context is a restore inhibit context, gfx hw only load the first page for ring context, so we only need to copy from guest the 1 page too. v3: use "return" instead of "goto" for inhibit case. (zhenyu wang) v2: move judgement of restore inhibit to a macro in mmio_context.h Signed-off-by: Zhao Yan <yan.y.zhao@intel.com> Acked-by: Hang Yuan <hang.yuan@linux.intel.com> Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
1 parent db47685 commit 8bfa02c

2 files changed

Lines changed: 34 additions & 29 deletions

File tree

‎drivers/gpu/drm/i915/gvt/mmio_context.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,8 @@ bool is_inhibit_context(struct intel_context *ce);
5353

5454
int intel_vgpu_restore_inhibit_context(struct intel_vgpu *vgpu,
5555
struct i915_request *req);
56+
#define IS_RESTORE_INHIBIT(a) \
57+
(_MASKED_BIT_ENABLE(CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT) == \
58+
((a) & _MASKED_BIT_ENABLE(CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT)))
5659

5760
#endif

‎drivers/gpu/drm/i915/gvt/scheduler.c‎

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -132,35 +132,6 @@ static int populate_shadow_context(struct intel_vgpu_workload *workload)
132132
unsigned long context_gpa, context_page_num;
133133
int i;
134134

135-
gvt_dbg_sched("ring id %d workload lrca %x", ring_id,
136-
workload->ctx_desc.lrca);
137-
138-
context_page_num = gvt->dev_priv->engine[ring_id]->context_size;
139-
140-
context_page_num = context_page_num >> PAGE_SHIFT;
141-
142-
if (IS_BROADWELL(gvt->dev_priv) && ring_id == RCS)
143-
context_page_num = 19;
144-
145-
i = 2;
146-
147-
while (i < context_page_num) {
148-
context_gpa = intel_vgpu_gma_to_gpa(vgpu->gtt.ggtt_mm,
149-
(u32)((workload->ctx_desc.lrca + i) <<
150-
I915_GTT_PAGE_SHIFT));
151-
if (context_gpa == INTEL_GVT_INVALID_ADDR) {
152-
gvt_vgpu_err("Invalid guest context descriptor\n");
153-
return -EFAULT;
154-
}
155-
156-
page = i915_gem_object_get_page(ctx_obj, LRC_HEADER_PAGES + i);
157-
dst = kmap(page);
158-
intel_gvt_hypervisor_read_gpa(vgpu, context_gpa, dst,
159-
I915_GTT_PAGE_SIZE);
160-
kunmap(page);
161-
i++;
162-
}
163-
164135
page = i915_gem_object_get_page(ctx_obj, LRC_STATE_PN);
165136
shadow_ring_context = kmap(page);
166137

@@ -195,6 +166,37 @@ static int populate_shadow_context(struct intel_vgpu_workload *workload)
195166

196167
sr_oa_regs(workload, (u32 *)shadow_ring_context, false);
197168
kunmap(page);
169+
170+
if (IS_RESTORE_INHIBIT(shadow_ring_context->ctx_ctrl.val))
171+
return 0;
172+
173+
gvt_dbg_sched("ring id %d workload lrca %x", ring_id,
174+
workload->ctx_desc.lrca);
175+
176+
context_page_num = gvt->dev_priv->engine[ring_id]->context_size;
177+
178+
context_page_num = context_page_num >> PAGE_SHIFT;
179+
180+
if (IS_BROADWELL(gvt->dev_priv) && ring_id == RCS)
181+
context_page_num = 19;
182+
183+
i = 2;
184+
while (i < context_page_num) {
185+
context_gpa = intel_vgpu_gma_to_gpa(vgpu->gtt.ggtt_mm,
186+
(u32)((workload->ctx_desc.lrca + i) <<
187+
I915_GTT_PAGE_SHIFT));
188+
if (context_gpa == INTEL_GVT_INVALID_ADDR) {
189+
gvt_vgpu_err("Invalid guest context descriptor\n");
190+
return -EFAULT;
191+
}
192+
193+
page = i915_gem_object_get_page(ctx_obj, LRC_HEADER_PAGES + i);
194+
dst = kmap(page);
195+
intel_gvt_hypervisor_read_gpa(vgpu, context_gpa, dst,
196+
I915_GTT_PAGE_SIZE);
197+
kunmap(page);
198+
i++;
199+
}
198200
return 0;
199201
}
200202

0 commit comments

Comments
 (0)