From patchwork Tue Jul 15 16:20:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Thierry X-Patchwork-Id: 4555431 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 F4090C0514 for ; Tue, 15 Jul 2014 16:21:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1591F20145 for ; Tue, 15 Jul 2014 16:21:11 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id DE9F120122 for ; Tue, 15 Jul 2014 16:21:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5FAF06E5C3; Tue, 15 Jul 2014 09:21:09 -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 9F6986E5C2 for ; Tue, 15 Jul 2014 09:21:07 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 15 Jul 2014 09:15:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,666,1400050800"; d="scan'208";a="573515371" Received: from michelth-linux.iwi.intel.com ([172.28.253.148]) by orsmga002.jf.intel.com with ESMTP; 15 Jul 2014 09:20:56 -0700 From: Michel Thierry To: intel-gfx@lists.freedesktop.org Date: Tue, 15 Jul 2014 17:20:44 +0100 Message-Id: <1405441251-28744-8-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 07/14] drm/i915/error: Do a better job of disambiguating VMAs 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 Some of the original PPGTT patches in this area where unmerged, and this left a lot of confusion in our error capture with regard to which vm/obj we want to capture. There have been at least a couple of patches from Chris, and myself to try to fix this up; so here is another shot. Nobody running without full PPGTT is effected by this, and that is probably why nobody has bothered to fix it yet. Instead of using any of the global lists to find the VMAs we want to capture, we use the union of the active, and the inactive list in the VM. This allows us to replace our capture_bo with capture_vma, and know all the VMAs we want to capture are valid. I could have probably figured out a way to reuse mm_list. As we've had bugs here before in the shrinker, I think the best way forward is to get it working, and then optimize it later. Signed-off-by: Ben Widawsky --- drivers/gpu/drm/i915/i915_gem_gtt.c | 1 + drivers/gpu/drm/i915/i915_gem_gtt.h | 2 ++ drivers/gpu/drm/i915/i915_gpu_error.c | 39 ++++++++++++++++++++++------------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index 5188936..0b2b982 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -2115,6 +2115,7 @@ static struct i915_vma *__i915_gem_vma_create(struct drm_i915_gem_object *obj, return ERR_PTR(-ENOMEM); INIT_LIST_HEAD(&vma->vma_link); + INIT_LIST_HEAD(&vma->pin_capture_link); INIT_LIST_HEAD(&vma->mm_list); INIT_LIST_HEAD(&vma->exec_list); vma->vm = vm; diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h index 8d6f7c1..1d75801 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.h +++ b/drivers/gpu/drm/i915/i915_gem_gtt.h @@ -126,6 +126,8 @@ struct i915_vma { struct list_head vma_link; /* Link in the object's VMA list */ + struct list_head pin_capture_link; /* Link in the error capture */ + /** This vma's place in the batchbuffer or on the eviction list */ struct list_head exec_list; diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c index ac101cd..4ff819e 100644 --- a/drivers/gpu/drm/i915/i915_gpu_error.c +++ b/drivers/gpu/drm/i915/i915_gpu_error.c @@ -677,14 +677,14 @@ static u32 capture_active_bo(struct drm_i915_error_buffer *err, static u32 capture_pinned_bo(struct drm_i915_error_buffer *err, int count, struct list_head *head) { - struct drm_i915_gem_object *obj; + struct i915_vma *vma; int i = 0; - list_for_each_entry(obj, head, global_list) { - if (!i915_gem_obj_is_pinned(obj)) + list_for_each_entry(vma, head, pin_capture_link) { + if (!i915_gem_obj_is_pinned(vma->obj)) continue; - capture_bo(err++, obj); + capture_bo(err++, vma->obj); if (++i == count) break; } @@ -1031,21 +1031,32 @@ static void i915_gem_capture_vm(struct drm_i915_private *dev_priv, 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 active_vma_count = 0; + int vma_pin_count = 0; + LIST_HEAD(pinned_vma); - list_for_each_entry(vma, &vm->active_list, mm_list) + list_for_each_entry(vma, &vm->active_list, mm_list) { active_vma_count++; + if (vma->pin_count) { + vma_pin_count++; + list_move_tail(&vma->pin_capture_link, &pinned_vma); + } + } - 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)) - active_vma_count++; + list_for_each_entry(vma, &vm->inactive_list, mm_list) { + /* Certain objects may be on the inactive list, but pinned, when + * in the global GGTT. */ + if (WARN_ON(!i915_is_ggtt(vm) && + vma->pin_count && + !(vma->exec_entry->flags & (1<<31)))) { /* FIXME: need the actual flag */ + vma_pin_count++; + list_move_tail(&vma->pin_capture_link, &pinned_vma); + } + } - /* XXX: this is an incorrect measurement of pinned BOs */ - error->pinned_bo_count[vm_ndx] = active_vma_count - error->active_bo_count[vm_ndx]; + error->active_bo_count[vm_ndx] = active_vma_count; + error->pinned_bo_count[vm_ndx] = vma_pin_count; if (active_vma_count) { active_bo = kcalloc(active_vma_count, sizeof(*active_bo), GFP_ATOMIC); @@ -1063,7 +1074,7 @@ static void i915_gem_capture_vm(struct drm_i915_private *dev_priv, error->pinned_bo_count[vm_ndx] = capture_pinned_bo(pinned_bo, error->pinned_bo_count[vm_ndx], - &dev_priv->mm.bound_list); + &pinned_vma); error->active_bo[vm_ndx] = active_bo; error->pinned_bo[vm_ndx] = pinned_bo; }