diff mbox

drm/i915: Show vma allocator stack when in doubt

Message ID 20180628082615.10805-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson June 28, 2018, 8:26 a.m. UTC
At the moment, gem_exec_gttfill fails with a sporadic EBUSY due to us
wanting to unbind a pinned batch. Let's dump who first bound that vma to
see if that helps us identify who still unexpectedly has it pinned.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_vma.c | 45 +++++++++++++++++++++++++++++++--
 1 file changed, 43 insertions(+), 2 deletions(-)

Comments

Chris Wilson June 28, 2018, 9 a.m. UTC | #1
Quoting Patchwork (2018-06-28 09:55:21)
> == Series Details ==
> 
> Series: drm/i915: Show vma allocator stack when in doubt
> URL   : https://patchwork.freedesktop.org/series/45562/
> State : failure
> 
> == Summary ==
> 
> = CI Bug Log - changes from CI_DRM_4396 -> Patchwork_9460 =
> 
> == Summary - FAILURE ==
> 
>   Serious unknown changes coming with Patchwork_9460 absolutely need to be
>   verified manually.
>   
>   If you think the reported changes have nothing to do with the changes
>   introduced in Patchwork_9460, please notify your bug team to allow them
>   to document this new failure mode, which will reduce false positives in CI.
> 
>   External URL: https://patchwork.freedesktop.org/api/1.0/series/45562/revisions/1/mbox/
> 
> == Possible new issues ==
> 
>   Here are the unknown changes that may have been introduced in Patchwork_9460:
> 
>   === IGT changes ===
> 
>     ==== Possible regressions ====
> 
>     igt@gem_exec_gttfill@basic:
>       {fi-kbl-x1275}:     PASS -> DMESG-WARN
>       fi-kbl-7500u:       PASS -> DMESG-WARN
>       fi-kbl-guc:         PASS -> DMESG-WARN
>       fi-skl-6600u:       PASS -> DMESG-WARN
>       fi-kbl-7560u:       PASS -> DMESG-WARN
>       fi-cfl-s3:          PASS -> DMESG-WARN
>       fi-skl-6770hq:      PASS -> DMESG-WARN
>       fi-skl-6700k2:      PASS -> DMESG-WARN
>       fi-skl-6260u:       PASS -> DMESG-WARN
>       fi-kbl-r:           PASS -> DMESG-WARN
>       fi-bdw-5557u:       PASS -> DMESG-WARN
>       fi-glk-j4005:       PASS -> DMESG-WARN
>       fi-kbl-7567u:       PASS -> DMESG-WARN
>       fi-skl-guc:         PASS -> DMESG-WARN
>       fi-cfl-8700k:       PASS -> DMESG-WARN
>       fi-whl-u:           PASS -> DMESG-WARN
>       fi-cfl-guc:         PASS -> DMESG-WARN
>       fi-bxt-j4205:       PASS -> DMESG-WARN
>       fi-skl-6700hq:      PASS -> DMESG-WARN

Allocation not allowed, hmm. Let's see just how much the stack can take!
-Chris
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
index e82aa804cdba..222787106169 100644
--- a/drivers/gpu/drm/i915/i915_vma.c
+++ b/drivers/gpu/drm/i915/i915_vma.c
@@ -21,7 +21,7 @@ 
  * IN THE SOFTWARE.
  *
  */
- 
+
 #include "i915_vma.h"
 
 #include "i915_drv.h"
@@ -30,6 +30,45 @@ 
 
 #include <drm/drm_gem.h>
 
+#if defined(CONFIG_DRM_I915_DEBUG_GEM) && defined(CONFIG_DRM_DEBUG_MM)
+
+#include <linux/stackdepot.h>
+
+static void vma_print_allocator(struct i915_vma *vma, const char *reason)
+{
+	unsigned long entries[16];
+	struct stack_trace trace = {
+		.entries = entries,
+		.max_entries = ARRAY_SIZE(entries),
+	};
+	char *buf;
+
+	if (!vma->node.stack) {
+		DRM_DEBUG_DRIVER("vma.node [%08llx + %08llx] %s: unknown owner\n",
+				 vma->node.start, vma->node.size, reason);
+		return;
+	}
+
+	buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+	if (!buf)
+		return;
+
+	depot_fetch_stack(vma->node.stack, &trace);
+	snprint_stack_trace(buf, PAGE_SIZE, &trace, 0);
+	DRM_DEBUG_DRIVER("vma.node [%08llx + %08llx] %s: inserted at %s\n",
+			 vma->node.start, vma->node.size, reason, buf);
+
+	kfree(buf);
+}
+
+#else
+
+static void vma_print_allocator(struct i915_vma *vma, const char *reason)
+{
+}
+
+#endif
+
 static void
 i915_vma_retire(struct i915_gem_active *active, struct i915_request *rq)
 {
@@ -875,8 +914,10 @@  int i915_vma_unbind(struct i915_vma *vma)
 	}
 	GEM_BUG_ON(i915_vma_is_active(vma));
 
-	if (i915_vma_is_pinned(vma))
+	if (i915_vma_is_pinned(vma)) {
+		vma_print_allocator(vma, "is pinned");
 		return -EBUSY;
+	}
 
 	if (!drm_mm_node_allocated(&vma->node))
 		return 0;