From patchwork Thu Mar 14 15:52:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Kuoppala X-Patchwork-Id: 2272141 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 F418CDFB79 for ; Thu, 14 Mar 2013 15:52:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EDED6E6495 for ; Thu, 14 Mar 2013 08:52:12 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [143.182.124.37]) by gabe.freedesktop.org (Postfix) with ESMTP id 469A4E6994 for ; Thu, 14 Mar 2013 08:48:48 -0700 (PDT) Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga102.ch.intel.com with ESMTP; 14 Mar 2013 08:48:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.84,845,1355126400"; d="scan'208";a="214714134" Received: from unknown (HELO rosetta) ([10.237.72.51]) by AZSMGA002.ch.intel.com with ESMTP; 14 Mar 2013 08:48:46 -0700 Received: by rosetta (Postfix, from userid 1000) id 6EA46800A0; 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:11 +0200 Message-Id: <1363276337-12509-11-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 10/16] drm/i915: add struct ctx_reset_state 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 To count context losses, add struct ctx_reset_state for both i915_hw_context and drm_i915_file_private. drm_i915_file_private is used when there is no context. Signed-off-by: Mika Kuoppala --- drivers/gpu/drm/i915/i915_dma.c | 4 +++- drivers/gpu/drm/i915/i915_drv.h | 19 +++++++++++++++++++ drivers/gpu/drm/i915/i915_gem_context.c | 11 +++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index e16099b..7902d97 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c @@ -1792,7 +1792,7 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file) struct drm_i915_file_private *file_priv; DRM_DEBUG_DRIVER("\n"); - file_priv = kmalloc(sizeof(*file_priv), GFP_KERNEL); + file_priv = kzalloc(sizeof(*file_priv), GFP_KERNEL); if (!file_priv) return -ENOMEM; @@ -1801,6 +1801,8 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file) spin_lock_init(&file_priv->mm.lock); INIT_LIST_HEAD(&file_priv->mm.request_list); + i915_gem_context_init_reset_state(dev, &file_priv->reset_state); + idr_init(&file_priv->context_idr); return 0; diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index a54c507..d004548 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -433,6 +433,19 @@ struct i915_hw_ppgtt { void (*cleanup)(struct i915_hw_ppgtt *ppgtt); }; +struct ctx_reset_state { + /* guilty and reset counts when context initialized */ + unsigned long guilty_cnt; + unsigned long reset_cnt; + + unsigned innocent; + unsigned guilty; + + unsigned long last_guilty_reset; + + /* banned to submit more work */ + bool banned; +}; /* This must match up with the value previously used for execbuf2.rsvd1. */ #define DEFAULT_CONTEXT_ID 0 @@ -443,6 +456,7 @@ struct i915_hw_context { struct drm_i915_file_private *file_priv; struct intel_ring_buffer *ring; struct drm_i915_gem_object *obj; + struct ctx_reset_state reset_state; }; enum no_fbc_reason { @@ -805,6 +819,7 @@ struct i915_gpu_error { unsigned long last_reset; + unsigned long guilty_cnt; /** * State variable and reset counter controlling the reset flow * @@ -1257,6 +1272,8 @@ struct drm_i915_file_private { struct list_head request_list; } mm; struct idr context_idr; + + struct ctx_reset_state reset_state; }; #define INTEL_INFO(dev) (((struct drm_i915_private *) (dev)->dev_private)->info) @@ -1677,6 +1694,8 @@ struct i915_hw_context * __must_check i915_switch_context(struct intel_ring_buffer *ring, struct drm_file *file, int to_id); void i915_gem_context_free(struct kref *ctx_ref); +void i915_gem_context_init_reset_state(struct drm_device *dev, + struct ctx_reset_state *rs); int i915_gem_context_create_ioctl(struct drm_device *dev, void *data, struct drm_file *file); int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data, diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 8fb4d3c..dbd14b8 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c @@ -145,6 +145,15 @@ static void do_destroy(struct i915_hw_context *ctx) kfree(ctx); } +void i915_gem_context_init_reset_state(struct drm_device *dev, + struct ctx_reset_state *rs) +{ + struct drm_i915_private *dev_priv = dev->dev_private; + + rs->reset_cnt = atomic_read(&dev_priv->gpu_error.reset_counter); + rs->guilty_cnt = dev_priv->gpu_error.guilty_cnt; +} + static struct i915_hw_context * create_hw_context(struct drm_device *dev, struct drm_i915_file_private *file_priv) @@ -177,6 +186,8 @@ create_hw_context(struct drm_device *dev, ctx->file_priv = file_priv; + i915_gem_context_init_reset_state(dev, &ctx->reset_state); + again: if (idr_pre_get(&file_priv->context_idr, GFP_KERNEL) == 0) { ret = -ENOMEM;