Skip to content

Commit 110f9ef

Browse files
icklejnikula
authored andcommitted
drm/i915/gt: Only swap to a random sibling once upon creation
The danger in switching at random upon intel_context_pin is that the context may still actually be inflight, as it will not be scheduled out until a context switch after it is complete -- that may be a long time after we do a final intel_context_unpin. Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/2118 Fixes: 6d06779 ("drm/i915: Load balancing across a virtual engine") Signed-off-by: Chris Wilson <[email protected]> Cc: Tvrtko Ursulin <[email protected]> Cc: <[email protected]> # v5.3+ Reviewed-by: Tvrtko Ursulin <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 90a9872) Signed-off-by: Jani Nikula <[email protected]>
1 parent 858f129 commit 110f9ef

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

drivers/gpu/drm/i915/gt/intel_lrc.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5396,13 +5396,8 @@ static void virtual_engine_initial_hint(struct virtual_engine *ve)
53965396
* typically be the first we inspect for submission.
53975397
*/
53985398
swp = prandom_u32_max(ve->num_siblings);
5399-
if (!swp)
5400-
return;
5401-
5402-
swap(ve->siblings[swp], ve->siblings[0]);
5403-
if (!intel_engine_has_relative_mmio(ve->siblings[0]))
5404-
virtual_update_register_offsets(ve->context.lrc_reg_state,
5405-
ve->siblings[0]);
5399+
if (swp)
5400+
swap(ve->siblings[swp], ve->siblings[0]);
54065401
}
54075402

54085403
static int virtual_context_alloc(struct intel_context *ce)
@@ -5415,15 +5410,9 @@ static int virtual_context_alloc(struct intel_context *ce)
54155410
static int virtual_context_pin(struct intel_context *ce)
54165411
{
54175412
struct virtual_engine *ve = container_of(ce, typeof(*ve), context);
5418-
int err;
54195413

54205414
/* Note: we must use a real engine class for setting up reg state */
5421-
err = __execlists_context_pin(ce, ve->siblings[0]);
5422-
if (err)
5423-
return err;
5424-
5425-
virtual_engine_initial_hint(ve);
5426-
return 0;
5415+
return __execlists_context_pin(ce, ve->siblings[0]);
54275416
}
54285417

54295418
static void virtual_context_enter(struct intel_context *ce)
@@ -5770,6 +5759,7 @@ intel_execlists_create_virtual(struct intel_engine_cs **siblings,
57705759

57715760
ve->base.flags |= I915_ENGINE_IS_VIRTUAL;
57725761

5762+
virtual_engine_initial_hint(ve);
57735763
return &ve->context;
57745764

57755765
err_put:

0 commit comments

Comments
 (0)