Skip to content

Commit 90a9872

Browse files
committed
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]
1 parent d292109 commit 90a9872

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
@@ -5432,13 +5432,8 @@ static void virtual_engine_initial_hint(struct virtual_engine *ve)
54325432
* typically be the first we inspect for submission.
54335433
*/
54345434
swp = prandom_u32_max(ve->num_siblings);
5435-
if (!swp)
5436-
return;
5437-
5438-
swap(ve->siblings[swp], ve->siblings[0]);
5439-
if (!intel_engine_has_relative_mmio(ve->siblings[0]))
5440-
virtual_update_register_offsets(ve->context.lrc_reg_state,
5441-
ve->siblings[0]);
5435+
if (swp)
5436+
swap(ve->siblings[swp], ve->siblings[0]);
54425437
}
54435438

54445439
static int virtual_context_alloc(struct intel_context *ce)
@@ -5451,15 +5446,9 @@ static int virtual_context_alloc(struct intel_context *ce)
54515446
static int virtual_context_pin(struct intel_context *ce)
54525447
{
54535448
struct virtual_engine *ve = container_of(ce, typeof(*ve), context);
5454-
int err;
54555449

54565450
/* Note: we must use a real engine class for setting up reg state */
5457-
err = __execlists_context_pin(ce, ve->siblings[0]);
5458-
if (err)
5459-
return err;
5460-
5461-
virtual_engine_initial_hint(ve);
5462-
return 0;
5451+
return __execlists_context_pin(ce, ve->siblings[0]);
54635452
}
54645453

54655454
static void virtual_context_enter(struct intel_context *ce)
@@ -5806,6 +5795,7 @@ intel_execlists_create_virtual(struct intel_engine_cs **siblings,
58065795

58075796
ve->base.flags |= I915_ENGINE_IS_VIRTUAL;
58085797

5798+
virtual_engine_initial_hint(ve);
58095799
return &ve->context;
58105800

58115801
err_put:

0 commit comments

Comments
 (0)