Commit 9888beaa authored by Matthew Brost's avatar Matthew Brost Committed by John Harrison

drm/i915/guc: Don't enable scheduling on a banned context, guc_id invalid, not registered

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: 62eaf0ae ("drm/i915/guc: Support request cancellation")
Signed-off-by: default avatarMatthew Brost <matthew.brost@intel.com>
Reviewed-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarJohn Harrison <John.C.Harrison@Intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210909164744.31249-10-matthew.brost@intel.com
parent cf37e5c8
...@@ -148,6 +148,7 @@ static inline void clr_context_registered(struct intel_context *ce) ...@@ -148,6 +148,7 @@ static inline void clr_context_registered(struct intel_context *ce)
#define SCHED_STATE_BLOCKED_SHIFT 4 #define SCHED_STATE_BLOCKED_SHIFT 4
#define SCHED_STATE_BLOCKED BIT(SCHED_STATE_BLOCKED_SHIFT) #define SCHED_STATE_BLOCKED BIT(SCHED_STATE_BLOCKED_SHIFT)
#define SCHED_STATE_BLOCKED_MASK (0xfff << SCHED_STATE_BLOCKED_SHIFT) #define SCHED_STATE_BLOCKED_MASK (0xfff << SCHED_STATE_BLOCKED_SHIFT)
static inline void init_sched_state(struct intel_context *ce) static inline void init_sched_state(struct intel_context *ce)
{ {
/* Only should be called from guc_lrc_desc_pin() */ /* Only should be called from guc_lrc_desc_pin() */
...@@ -1563,6 +1564,23 @@ static struct i915_sw_fence *guc_context_block(struct intel_context *ce) ...@@ -1563,6 +1564,23 @@ static struct i915_sw_fence *guc_context_block(struct intel_context *ce)
return &ce->guc_blocked; 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) static void guc_context_unblock(struct intel_context *ce)
{ {
struct intel_guc *guc = ce_to_guc(ce); struct intel_guc *guc = ce_to_guc(ce);
...@@ -1577,9 +1595,7 @@ static void guc_context_unblock(struct intel_context *ce) ...@@ -1577,9 +1595,7 @@ static void guc_context_unblock(struct intel_context *ce)
spin_lock_irqsave(&ce->guc_state.lock, flags); spin_lock_irqsave(&ce->guc_state.lock, flags);
if (unlikely(submission_disabled(guc) || if (unlikely(submission_disabled(guc) ||
!intel_context_is_pinned(ce) || context_cant_unblock(ce))) {
context_pending_disable(ce) ||
context_blocked(ce) > 1)) {
enable = false; enable = false;
} else { } else {
enable = true; enable = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment