Skip to content

Commit baec997

Browse files
coxuintelzhenyw
authored andcommitted
drm/i915/gvt: Only pin/unpin intel_context along with workload
One issue exposed after below commit with which the system will freeze at suspend after vGPU is created (no need to activate the vGPU). commit e6ba764 ("drm/i915: Remove i915->kernel_context") Old implementation pin the intel_context at setup_submission and unpin it at clean_submission. So after some vGPU is created, the intel_context is always pinned there although no workload using it. It will then block i915 enter suspend state. There is no need to pin it all the time. Pin/unpin it around workload lifecycle is more reasonable. After GVT enabled suspend/resume, the pinned intel_context will also get unpined when userspace put VM process into suspend state since all workloads are retired, then it's safe to unpin all intel_context for workloads created. So move the pin/unpin to create_workload and destroy_workload, while still keep the create/destroy in old place. V2: Rebase. Fixes: e6ba764 ("drm/i915: Remove i915->kernel_context") Reviewed-by: Zhenyu Wang <zhenyuw@linux.intel.com> Signed-off-by: Colin Xu <colin.xu@intel.com> Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/20201016054059.238371-1-colin.xu@intel.com
1 parent 8fe1056 commit baec997

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,7 @@ void intel_vgpu_clean_submission(struct intel_vgpu *vgpu)
12681268

12691269
i915_context_ppgtt_root_restore(s, i915_vm_to_ppgtt(s->shadow[0]->vm));
12701270
for_each_engine(engine, vgpu->gvt->gt, id)
1271-
intel_context_unpin(s->shadow[id]);
1271+
intel_context_put(s->shadow[id]);
12721272

12731273
kmem_cache_destroy(s->workloads);
12741274
}
@@ -1360,11 +1360,6 @@ int intel_vgpu_setup_submission(struct intel_vgpu *vgpu)
13601360
ce->ring = __intel_context_ring_size(ring_size);
13611361
}
13621362

1363-
ret = intel_context_pin(ce);
1364-
intel_context_put(ce);
1365-
if (ret)
1366-
goto out_shadow_ctx;
1367-
13681363
s->shadow[i] = ce;
13691364
}
13701365

@@ -1396,7 +1391,6 @@ int intel_vgpu_setup_submission(struct intel_vgpu *vgpu)
13961391
if (IS_ERR(s->shadow[i]))
13971392
break;
13981393

1399-
intel_context_unpin(s->shadow[i]);
14001394
intel_context_put(s->shadow[i]);
14011395
}
14021396
i915_vm_put(&ppgtt->vm);
@@ -1470,6 +1464,7 @@ void intel_vgpu_destroy_workload(struct intel_vgpu_workload *workload)
14701464
{
14711465
struct intel_vgpu_submission *s = &workload->vgpu->submission;
14721466

1467+
intel_context_unpin(s->shadow[workload->engine->id]);
14731468
release_shadow_batch_buffer(workload);
14741469
release_shadow_wa_ctx(&workload->wa_ctx);
14751470

@@ -1715,6 +1710,12 @@ intel_vgpu_create_workload(struct intel_vgpu *vgpu,
17151710
return ERR_PTR(ret);
17161711
}
17171712

1713+
ret = intel_context_pin(s->shadow[engine->id]);
1714+
if (ret) {
1715+
intel_vgpu_destroy_workload(workload);
1716+
return ERR_PTR(ret);
1717+
}
1718+
17181719
return workload;
17191720
}
17201721

0 commit comments

Comments
 (0)