mirror of
https://github.com/torvalds/linux.git
synced 2026-04-22 16:53:59 -04:00
drm/i915: Move context management under GEM
Keep track of the GEM contexts underneath i915->gem.contexts and assign them their own lock for the purposes of list management. v2: Focus on lock tracking; ctx->vm is protected by ctx->mutex v3: Correct split with removal of logical HW ID Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20191004134015.13204-15-chris@chris-wilson.co.uk
This commit is contained in:
@@ -365,7 +365,8 @@ static void set_context_ppgtt_from_shadow(struct intel_vgpu_workload *workload,
|
||||
struct i915_gem_context *ctx)
|
||||
{
|
||||
struct intel_vgpu_mm *mm = workload->shadow_mm;
|
||||
struct i915_ppgtt *ppgtt = i915_vm_to_ppgtt(ctx->vm);
|
||||
struct i915_ppgtt *ppgtt =
|
||||
i915_vm_to_ppgtt(i915_gem_context_get_vm_rcu(ctx));
|
||||
int i = 0;
|
||||
|
||||
if (mm->ppgtt_mm.root_entry_type == GTT_TYPE_PPGTT_ROOT_L4_ENTRY) {
|
||||
@@ -378,6 +379,8 @@ static void set_context_ppgtt_from_shadow(struct intel_vgpu_workload *workload,
|
||||
px_dma(pd) = mm->ppgtt_mm.shadow_pdps[i];
|
||||
}
|
||||
}
|
||||
|
||||
i915_vm_put(&ppgtt->vm);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -1213,20 +1216,18 @@ int intel_vgpu_setup_submission(struct intel_vgpu *vgpu)
|
||||
struct intel_vgpu_submission *s = &vgpu->submission;
|
||||
struct intel_engine_cs *engine;
|
||||
struct i915_gem_context *ctx;
|
||||
struct i915_ppgtt *ppgtt;
|
||||
enum intel_engine_id i;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&i915->drm.struct_mutex);
|
||||
|
||||
ctx = i915_gem_context_create_kernel(i915, I915_PRIORITY_MAX);
|
||||
if (IS_ERR(ctx)) {
|
||||
ret = PTR_ERR(ctx);
|
||||
goto out_unlock;
|
||||
}
|
||||
if (IS_ERR(ctx))
|
||||
return PTR_ERR(ctx);
|
||||
|
||||
i915_gem_context_set_force_single_submission(ctx);
|
||||
|
||||
i915_context_ppgtt_root_save(s, i915_vm_to_ppgtt(ctx->vm));
|
||||
ppgtt = i915_vm_to_ppgtt(i915_gem_context_get_vm_rcu(ctx));
|
||||
i915_context_ppgtt_root_save(s, ppgtt);
|
||||
|
||||
for_each_engine(engine, i915, i) {
|
||||
struct intel_context *ce;
|
||||
@@ -1271,12 +1272,12 @@ int intel_vgpu_setup_submission(struct intel_vgpu *vgpu)
|
||||
atomic_set(&s->running_workload_num, 0);
|
||||
bitmap_zero(s->tlb_handle_pending, I915_NUM_ENGINES);
|
||||
|
||||
i915_vm_put(&ppgtt->vm);
|
||||
i915_gem_context_put(ctx);
|
||||
mutex_unlock(&i915->drm.struct_mutex);
|
||||
return 0;
|
||||
|
||||
out_shadow_ctx:
|
||||
i915_context_ppgtt_root_restore(s, i915_vm_to_ppgtt(ctx->vm));
|
||||
i915_context_ppgtt_root_restore(s, ppgtt);
|
||||
for_each_engine(engine, i915, i) {
|
||||
if (IS_ERR(s->shadow[i]))
|
||||
break;
|
||||
@@ -1284,9 +1285,8 @@ out_shadow_ctx:
|
||||
intel_context_unpin(s->shadow[i]);
|
||||
intel_context_put(s->shadow[i]);
|
||||
}
|
||||
i915_vm_put(&ppgtt->vm);
|
||||
i915_gem_context_put(ctx);
|
||||
out_unlock:
|
||||
mutex_unlock(&i915->drm.struct_mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user