From patchwork Thu Mar 14 15:52:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Kuoppala X-Patchwork-Id: 2272241 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 D1F46DFB79 for ; Thu, 14 Mar 2013 15:57:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C8F96E648D for ; Thu, 14 Mar 2013 08:57:37 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 599C6E697B for ; Thu, 14 Mar 2013 08:49:16 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 14 Mar 2013 08:49:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.84,845,1355126400"; d="scan'208";a="302178381" Received: from unknown (HELO rosetta) ([10.237.72.51]) by orsmga002.jf.intel.com with ESMTP; 14 Mar 2013 08:48:48 -0700 Received: by rosetta (Postfix, from userid 1000) id 93E21800AE; Thu, 14 Mar 2013 17:52:22 +0200 (EET) From: Mika Kuoppala To: intel-gfx@lists.freedesktop.org Date: Thu, 14 Mar 2013 17:52:16 +0200 Message-Id: <1363276337-12509-16-git-send-email-mika.kuoppala@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1363276337-12509-1-git-send-email-mika.kuoppala@intel.com> References: <1363276337-12509-1-git-send-email-mika.kuoppala@intel.com> Cc: miku@iki.fi Subject: [Intel-gfx] [PATCH v2 15/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 | 1 + drivers/gpu/drm/i915/i915_gem.c | 1 + drivers/gpu/drm/i915/i915_gem_execbuffer.c | 11 +++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index 1ebed96..69c9856 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c @@ -817,6 +817,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 ctx_reset_state *gstate; + bool do_wedge = true; int ret; if (!i915_try_reset) @@ -824,10 +826,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.guilty_state = NULL; + i915_gem_reset(dev); + gstate = dev_priv->gpu_error.guilty_state; + + if (gstate) { + if (gstate->guilty == 1) { + do_wedge = false; + } else if (!gstate->banned && + get_seconds() - gstate->last_guilty_reset < 5) { + gstate->banned = true; + do_wedge = false; + } + + gstate->last_guilty_reset = get_seconds(); + } + + dev_priv->gpu_error.guilty_state = 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 1a4cba0..3e11acf 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -818,6 +818,7 @@ struct i915_gpu_error { struct work_struct work; unsigned long last_reset; + struct ctx_reset_state *guilty_state; unsigned long guilty_cnt; /** diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 6d3916a..de7403f 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -2175,6 +2175,7 @@ static void i915_set_reset_status(struct intel_ring_buffer *ring, if (guilty) { rs->guilty++; dev_priv->gpu_error.guilty_cnt++; + dev_priv->gpu_error.guilty_state = rs; } else { rs->innocent++; } diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index 2f23013..97d3887 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c @@ -841,6 +841,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 ctx_reset_state *rs; u32 ctx_id = i915_execbuffer2_get_context_id(*args); u32 exec_start, exec_len; u32 mask, flags; @@ -1023,6 +1024,16 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, if (ret) goto err; + ret = i915_gem_context_get_reset_state(&dev_priv->ring[RCS], + file, ctx_id, &rs); + if (ret) + goto err; + + if (rs->banned) { + ret = -EIO; + goto err; + } + ctx = i915_switch_context(ring, file, ctx_id); if (IS_ERR(ctx)) { ret = PTR_ERR(ctx);