From patchwork Fri Aug 22 03:11:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 4760541 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 713C09F377 for ; Fri, 22 Aug 2014 03:12:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6DF54201BA for ; Fri, 22 Aug 2014 03:12:52 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7D9C820173 for ; Fri, 22 Aug 2014 03:12:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0CA006E857; Thu, 21 Aug 2014 20:12:51 -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 [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTP id 8D6716E84E for ; Thu, 21 Aug 2014 20:12:47 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 21 Aug 2014 20:04:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,862,1389772800"; d="scan'208";a="375575669" Received: from unknown (HELO ironside.intel.com) ([10.255.12.192]) by FMSMGA003.fm.intel.com with ESMTP; 21 Aug 2014 20:08:53 -0700 From: Ben Widawsky To: Intel GFX Date: Thu, 21 Aug 2014 20:11:29 -0700 Message-Id: <1408677155-1840-7-git-send-email-benjamin.widawsky@intel.com> X-Mailer: git-send-email 2.0.4 In-Reply-To: <1408677155-1840-1-git-send-email-benjamin.widawsky@intel.com> References: <1408677155-1840-1-git-send-email-benjamin.widawsky@intel.com> Cc: Ben Widawsky , Ben Widawsky Subject: [Intel-gfx] [PATCH 06/68] 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.9 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 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 eab41f9..470cc97 100644 --- a/drivers/gpu/drm/i915/i915_gpu_error.c +++ b/drivers/gpu/drm/i915/i915_gpu_error.c @@ -1032,63 +1032,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)