drm/i915: Add per client max context ban limit
If we have a bad client submitting unfavourably across different
contexts, creating new ones, the per context scoring of badness
doesn't remove the root cause, the offending client.
To counter, keep track of per client context bans. Deny access if
client is responsible for more than 3 context bans in
it's lifetime.
v2: move ban check to context create ioctl (Chris)
v3: add commentary about hangs needed to reach client ban (Chris)
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 9919814..a811838 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2646,6 +2646,20 @@
hs->banned = i915_context_is_banned(ctx);
hs->batch_active++;
+
+ DRM_DEBUG_DRIVER("context %s marked guilty (score %d) banned? %s\n",
+ ctx->name, hs->ban_score, yesno(hs->banned));
+
+ if (!ctx->file_priv)
+ return;
+
+ if (hs->banned) {
+ ctx->file_priv->context_bans++;
+
+ DRM_DEBUG_DRIVER("client %s has has %d context banned\n",
+ ctx->name,
+ ctx->file_priv->context_bans);
+ }
}
static void i915_gem_context_mark_innocent(struct i915_gem_context *ctx)