From patchwork Thu Apr 4 15:32:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Kuoppala X-Patchwork-Id: 2393381 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 2D124DF25A for ; Thu, 4 Apr 2013 15:34:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 000CEE6448 for ; Thu, 4 Apr 2013 08:34:06 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id D41D8E6447 for ; Thu, 4 Apr 2013 08:28:33 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 04 Apr 2013 08:28:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,409,1363158000"; d="scan'208";a="313645119" Received: from rosetta.fi.intel.com (HELO rosetta) ([10.237.72.186]) by fmsmga001.fm.intel.com with ESMTP; 04 Apr 2013 08:28:32 -0700 Received: by rosetta (Postfix, from userid 1000) id 4735F800A4; Thu, 4 Apr 2013 18:32:51 +0300 (EEST) From: Mika Kuoppala To: intel-gfx@lists.freedesktop.org Date: Thu, 4 Apr 2013 18:32:46 +0300 Message-Id: <1365089568-20457-15-git-send-email-mika.kuoppala@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1365089568-20457-1-git-send-email-mika.kuoppala@intel.com> References: <1365089568-20457-1-git-send-email-mika.kuoppala@intel.com> Subject: [Intel-gfx] [PATCH v3 14/16] drm/i915: refuse to submit more batchbuffers from guilty context X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org If context has recently submitted a faulty batchbuffers guilty of gpu hang and decides to keep submitting more crap, ban it permanently. Signed-off-by: Mika Kuoppala --- drivers/gpu/drm/i915/i915_drv.c | 23 ++++++++++++++++++++++- drivers/gpu/drm/i915/i915_drv.h | 7 +++++++ drivers/gpu/drm/i915/i915_gem.c | 7 +++++-- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 13 +++++++++++++ 4 files changed, 47 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index a5b8aa9..0928f11 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c @@ -852,6 +852,8 @@ int intel_gpu_reset(struct drm_device *dev) int i915_reset(struct drm_device *dev) { drm_i915_private_t *dev_priv = dev->dev_private; + struct i915_ctx_hang_stats *hs; + bool do_wedge = true; int ret; if (!i915_try_reset) @@ -859,10 +861,29 @@ int i915_reset(struct drm_device *dev) mutex_lock(&dev->struct_mutex); + /* i915_gem_reset will set this if it finds guilty context */ + dev_priv->gpu_error.hang_stats = NULL; + i915_gem_reset(dev); + hs = dev_priv->gpu_error.hang_stats; + + if (hs) { + if (hs->batch_active == 1) { + do_wedge = false; + } else if (!hs->banned && + get_seconds() - hs->batch_active_reset_ts < 5) { + hs->banned = true; + do_wedge = false; + } + + hs->batch_active_reset_ts = get_seconds(); + } + + dev_priv->gpu_error.hang_stats = NULL; + ret = -ENODEV; - if (get_seconds() - dev_priv->gpu_error.last_reset < 5) + if (do_wedge && get_seconds() - dev_priv->gpu_error.last_reset < 5) DRM_ERROR("GPU hanging too fast, declaring wedged!\n"); else ret = intel_gpu_reset(dev); diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 8223908..30ba79c 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -458,6 +458,12 @@ struct i915_ctx_hang_stats { /* This context had batch active when hang was declared */ unsigned batch_active; + + /* Time when this context was last blamed for a GPU reset */ + unsigned long batch_active_reset_ts; + + /* This context is banned to submit more work */ + bool banned; }; /* This must match up with the value previously used for execbuf2.rsvd1. */ @@ -831,6 +837,7 @@ struct i915_gpu_error { struct work_struct work; unsigned long last_reset; + struct i915_ctx_hang_stats *hang_stats; /** * State variable and reset counter controlling the reset flow diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 475b6ad..ca5c9c3 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -2147,6 +2147,7 @@ static void i915_set_reset_status(struct intel_ring_buffer *ring, struct drm_i915_gem_request *request, u32 acthd) { + struct drm_i915_private *dev_priv = ring->dev->dev_private; struct i915_ctx_hang_stats *hs = NULL; bool inside, guilty; @@ -2175,10 +2176,12 @@ static void i915_set_reset_status(struct intel_ring_buffer *ring, hs = &request->file_priv->hang_stats; if (hs) { - if (guilty) + if (guilty) { hs->batch_active++; - else + dev_priv->gpu_error.hang_stats = hs; + } else { hs->batch_pending++; + } } } diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index bd1750a..f1b1ea9 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c @@ -844,6 +844,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, struct drm_clip_rect *cliprects = NULL; struct intel_ring_buffer *ring; struct i915_hw_context *ctx; + struct i915_ctx_hang_stats *hs; u32 ctx_id = i915_execbuffer2_get_context_id(*args); u32 exec_start, exec_len; u32 mask, flags; @@ -1026,6 +1027,18 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, if (ret) goto err; + hs = i915_gem_context_get_hang_stats(&dev_priv->ring[RCS], + file, ctx_id); + if (IS_ERR(hs)) { + ret = PTR_ERR(hs); + goto err; + } + + if (hs->banned) { + ret = -EIO; + goto err; + } + ctx = i915_switch_context(ring, file, ctx_id); if (IS_ERR(ctx)) { ret = PTR_ERR(ctx);