[PATCH v6 31/34] drm/i915: Add support for retro-actively banning batch buffers

John.C.Harrison
2016-04-20T17:14:35Z

If a given context submits too many hanging batch buffers then it will
be banned and no further batch buffers will be accepted for it.
However, it is possible that a large number of buffers may already
have been accepted and are sat in the scheduler waiting to be
executed. This patch adds a late ban check to ensure that these will
also be discarded.

v4: New patch in series.

For: VIZ-1587
Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
---
drivers/gpu/drm/i915/i915_gem_execbuffer.c | 6 ++++++
drivers/gpu/drm/i915/intel_lrc.c | 6 ++++++
2 files changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index fc663fa..789f668 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1293,6 +1293,12 @@ int i915_gem_ringbuffer_submission_final(struct i915_execbuffer_params *params)
/* The mutex must be acquired before calling this function */
WARN_ON(!mutex_is_locked(&params->dev->struct_mutex));

+ /* Check the context wasn't banned between submission and execution: */
+ if (params->ctx->hang_stats.banned) {
+ DRM_DEBUG("Trying to execute for banned context!\n");
+ return -ENOENT;
+ }
+
/* Make sure the request's seqno is the latest and greatest: */
if (req->reserved_seqno != dev_priv->last_seqno) {
ret = i915_gem_get_seqno(engine->dev, &req->reserved_seqno);
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index b9258ee..02808f7 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -1034,6 +1034,12 @@ int intel_execlists_submission_final(struct i915_execbuffer_params *params)
/* The mutex must be acquired before calling this function */
WARN_ON(!mutex_is_locked(&params->dev->struct_mutex));

+ /* Check the context wasn't banned between submission and execution: */
+ if (params->ctx->hang_stats.banned) {
+ DRM_DEBUG("Trying to execute for banned context!\n");
+ return -ENOENT;
+ }
+
/* Make sure the request's seqno is the latest and greatest: */
if (req->reserved_seqno != dev_priv->last_seqno) {
ret = i915_gem_get_seqno(engine->dev, &req->reserved_seqno);