This is a note to let you know that I've just added the patch titled drm/i915/guc: Don't enable scheduling on a banned context, guc_id invalid, not registered to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: drm-i915-guc-don-t-enable-scheduling-on-a-banned-context-guc_id-invalid-not-registered.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 9888beaaf118b6878347e1fe2b369fc66d756d18 Mon Sep 17 00:00:00 2001 From: Matthew Brost <matthew.brost@xxxxxxxxx> Date: Thu, 9 Sep 2021 09:47:30 -0700 Subject: drm/i915/guc: Don't enable scheduling on a banned context, guc_id invalid, not registered From: Matthew Brost <matthew.brost@xxxxxxxxx> commit 9888beaaf118b6878347e1fe2b369fc66d756d18 upstream. When unblocking a context, do not enable scheduling if the context is banned, guc_id invalid, or not registered. v2: (Daniele) - Add helper for unblock Fixes: 62eaf0ae217d ("drm/i915/guc: Support request cancellation") Signed-off-by: Matthew Brost <matthew.brost@xxxxxxxxx> Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@xxxxxxxxx> Cc: <stable@xxxxxxxxxxxxxxx> Signed-off-by: John Harrison <John.C.Harrison@xxxxxxxxx> Link: https://patchwork.freedesktop.org/patch/msgid/20210909164744.31249-10-matthew.brost@xxxxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c @@ -148,6 +148,7 @@ static inline void clr_context_registere #define SCHED_STATE_BLOCKED_SHIFT 4 #define SCHED_STATE_BLOCKED BIT(SCHED_STATE_BLOCKED_SHIFT) #define SCHED_STATE_BLOCKED_MASK (0xfff << SCHED_STATE_BLOCKED_SHIFT) + static inline void init_sched_state(struct intel_context *ce) { /* Only should be called from guc_lrc_desc_pin() */ @@ -1549,6 +1550,23 @@ static struct i915_sw_fence *guc_context return &ce->guc_blocked; } +#define SCHED_STATE_MULTI_BLOCKED_MASK \ + (SCHED_STATE_BLOCKED_MASK & ~SCHED_STATE_BLOCKED) +#define SCHED_STATE_NO_UNBLOCK \ + (SCHED_STATE_MULTI_BLOCKED_MASK | \ + SCHED_STATE_PENDING_DISABLE | \ + SCHED_STATE_BANNED) + +static bool context_cant_unblock(struct intel_context *ce) +{ + lockdep_assert_held(&ce->guc_state.lock); + + return (ce->guc_state.sched_state & SCHED_STATE_NO_UNBLOCK) || + context_guc_id_invalid(ce) || + !lrc_desc_registered(ce_to_guc(ce), ce->guc_id) || + !intel_context_is_pinned(ce); +} + static void guc_context_unblock(struct intel_context *ce) { struct intel_guc *guc = ce_to_guc(ce); @@ -1563,9 +1581,7 @@ static void guc_context_unblock(struct i spin_lock_irqsave(&ce->guc_state.lock, flags); if (unlikely(submission_disabled(guc) || - !intel_context_is_pinned(ce) || - context_pending_disable(ce) || - context_blocked(ce) > 1)) { + context_cant_unblock(ce))) { enable = false; } else { enable = true; Patches currently in stable-queue which might be from matthew.brost@xxxxxxxxx are queue-5.15/drm-i915-guc-don-t-drop-ce-guc_active.lock-when-unwinding-context.patch queue-5.15/drm-i915-guc-workaround-reset-g2h-is-received-after-schedule-done-g2h.patch queue-5.15/drm-i915-guc-fix-outstanding-g2h-accounting.patch queue-5.15/drm-i915-guc-don-t-enable-scheduling-on-a-banned-context-guc_id-invalid-not-registered.patch queue-5.15/drm-i915-guc-unwind-context-requests-in-reverse-order.patch