From patchwork Tue Jul 1 18:17:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 4461201 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E42EF9F3FF for ; Tue, 1 Jul 2014 18:18:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1919820364 for ; Tue, 1 Jul 2014 18:18:45 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 294C22034B for ; Tue, 1 Jul 2014 18:18:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 21DE46E1D4; Tue, 1 Jul 2014 11:18:43 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id C944C6E1C2 for ; Tue, 1 Jul 2014 11:18:41 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 01 Jul 2014 11:12:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,583,1400050800"; d="scan'208";a="537317968" Received: from ironside.jf.intel.com ([10.7.197.210]) by orsmga001.jf.intel.com with ESMTP; 01 Jul 2014 11:17:53 -0700 From: Ben Widawsky To: Intel GFX Date: Tue, 1 Jul 2014 11:17:42 -0700 Message-Id: <1404238671-18760-8-git-send-email-benjamin.widawsky@intel.com> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1404238671-18760-1-git-send-email-benjamin.widawsky@intel.com> References: <1404238671-18760-1-git-send-email-benjamin.widawsky@intel.com> Cc: Ben Widawsky , Ben Widawsky Subject: [Intel-gfx] [PATCH 07/16] drm/i915/error: vma error capture prettyify X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Rename some variables, and clean up the code a bit to make things clearer in our error capture. There isn't an intentional functional change here. Signed-off-by: Ben Widawsky --- drivers/gpu/drm/i915/i915_gpu_error.c | 55 ++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c index 550ba38..ebe2904 100644 --- a/drivers/gpu/drm/i915/i915_gpu_error.c +++ b/drivers/gpu/drm/i915/i915_gpu_error.c @@ -967,63 +967,72 @@ static void i915_gem_record_rings(struct drm_device *dev, } } -/* FIXME: Since pin count/bound list is global, we duplicate what we capture per +/** + * i915_gem_capture_vm() - Capture a VMs error state. + * @error: The main error structure + * @vm: The address space we're capturing. + * @vm_ndx: Which vm without the buffer array + * + * FIXME: Since pin count/bound list is global, we duplicate what we capture per * VM. */ static void i915_gem_capture_vm(struct drm_i915_private *dev_priv, struct drm_i915_error_state *error, struct i915_address_space *vm, - const int ndx) + const int vm_ndx) { struct drm_i915_error_buffer *active_bo = NULL, *pinned_bo = NULL; struct drm_i915_gem_object *obj; struct i915_vma *vma; - int i; + int active_vma_count = 0; - i = 0; list_for_each_entry(vma, &vm->active_list, mm_list) - i++; - error->active_bo_count[ndx] = i; + active_vma_count++; + + error->active_bo_count[vm_ndx] = active_vma_count; + list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) if (i915_gem_obj_is_pinned(obj)) - i++; - error->pinned_bo_count[ndx] = i - error->active_bo_count[ndx]; + active_vma_count++; + + /* XXX: this is an incorrect measurement of pinned BOs */ + error->pinned_bo_count[vm_ndx] = active_vma_count - error->active_bo_count[vm_ndx]; - if (i) { - active_bo = kcalloc(i, sizeof(*active_bo), GFP_ATOMIC); + if (active_vma_count) { + active_bo = kcalloc(active_vma_count, sizeof(*active_bo), GFP_ATOMIC); if (active_bo) - pinned_bo = active_bo + error->active_bo_count[ndx]; + pinned_bo = active_bo + error->active_bo_count[vm_ndx]; } if (active_bo) - error->active_bo_count[ndx] = + error->active_bo_count[vm_ndx] = capture_active_bo(active_bo, - error->active_bo_count[ndx], + error->active_bo_count[vm_ndx], &vm->active_list); if (pinned_bo) - error->pinned_bo_count[ndx] = + error->pinned_bo_count[vm_ndx] = capture_pinned_bo(pinned_bo, - error->pinned_bo_count[ndx], + error->pinned_bo_count[vm_ndx], &dev_priv->mm.bound_list); - error->active_bo[ndx] = active_bo; - error->pinned_bo[ndx] = pinned_bo; + error->active_bo[vm_ndx] = active_bo; + error->pinned_bo[vm_ndx] = pinned_bo; } static void i915_gem_capture_buffers(struct drm_i915_private *dev_priv, struct drm_i915_error_state *error) { struct i915_address_space *vm; - int cnt = 0, i = 0; + int vm_count = 0, i = 0; list_for_each_entry(vm, &dev_priv->vm_list, global_link) - cnt++; + vm_count++; - error->active_bo = kcalloc(cnt, sizeof(*error->active_bo), GFP_ATOMIC); - error->pinned_bo = kcalloc(cnt, sizeof(*error->pinned_bo), GFP_ATOMIC); - error->active_bo_count = kcalloc(cnt, sizeof(*error->active_bo_count), + error->active_bo = kcalloc(vm_count, sizeof(*error->active_bo), GFP_ATOMIC); + error->pinned_bo = kcalloc(vm_count, sizeof(*error->pinned_bo), GFP_ATOMIC); + error->active_bo_count = kcalloc(vm_count, sizeof(*error->active_bo_count), GFP_ATOMIC); - error->pinned_bo_count = kcalloc(cnt, sizeof(*error->pinned_bo_count), + error->pinned_bo_count = kcalloc(vm_count, sizeof(*error->pinned_bo_count), GFP_ATOMIC); list_for_each_entry(vm, &dev_priv->vm_list, global_link)