From patchwork Tue Jul 15 16:20:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Thierry X-Patchwork-Id: 4555411 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3D4B3C0514 for ; Tue, 15 Jul 2014 16:21:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5AE6A20122 for ; Tue, 15 Jul 2014 16:21:03 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7259120120 for ; Tue, 15 Jul 2014 16:21:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F3A776E5C0; Tue, 15 Jul 2014 09:21:01 -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 EEE566E5C0 for ; Tue, 15 Jul 2014 09:21:00 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 15 Jul 2014 09:15:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,666,1400050800"; d="scan'208";a="573515321" Received: from michelth-linux.iwi.intel.com ([172.28.253.148]) by orsmga002.jf.intel.com with ESMTP; 15 Jul 2014 09:20:55 -0700 From: Michel Thierry To: intel-gfx@lists.freedesktop.org Date: Tue, 15 Jul 2014 17:20:43 +0100 Message-Id: <1405441251-28744-7-git-send-email-michel.thierry@intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1405441251-28744-1-git-send-email-michel.thierry@intel.com> References: <1405441251-28744-1-git-send-email-michel.thierry@intel.com> Subject: [Intel-gfx] [PATCH 06/14] 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, 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 From: Ben Widawsky 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 9faebbc..ac101cd 100644 --- a/drivers/gpu/drm/i915/i915_gpu_error.c +++ b/drivers/gpu/drm/i915/i915_gpu_error.c @@ -1016,63 +1016,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)