[PATCH 12/16] [DEBUG] dump busy debug

Robert Beckett bob.beckett at collabora.com
Sun Jun 26 17:50:01 UTC 2022


---
 drivers/gpu/drm/i915/gt/selftest_reset.c | 43 +++++++++++++++++++++---
 drivers/gpu/drm/i915/intel_region_ttm.c  | 27 +++++++++++++++
 drivers/gpu/drm/i915/intel_region_ttm.h  | 13 +++++++
 3 files changed, 78 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/selftest_reset.c b/drivers/gpu/drm/i915/gt/selftest_reset.c
index 1d353576bb6b..5c37950c3e85 100644
--- a/drivers/gpu/drm/i915/gt/selftest_reset.c
+++ b/drivers/gpu/drm/i915/gt/selftest_reset.c
@@ -75,6 +75,7 @@ __igt_reset_stolen(struct intel_gt *gt,
 	u32 *crc;
 	int err;
 	struct page **orig;
+	struct ttm_resource_dbg *orig_busy;
 
 	if (!drm_mm_node_allocated(&ggtt->error_capture))
 		return 0;
@@ -83,10 +84,18 @@ __igt_reset_stolen(struct intel_gt *gt,
 	if (!num_pages)
 		return 0;
 
+	orig_busy = vmalloc_array(num_pages, sizeof(*orig_busy));
+	if (!orig_busy) {
+		pr_err("BOB_DEBUG: %s(): failed to alloc orig_busy. size=0x%llx\n",
+				__func__, num_pages * sizeof(orig_busy));
+		return -ENOMEM;
+	}
+
 	orig = alloc_orig(num_pages);
 	if (!orig) {
 		pr_err("BOB_DEBUG: %s(): failed to alloc orig. sz=0x%llx\n", __func__, num_pages * sizeof(struct page*));
-		return -ENOMEM;
+		err = -ENOMEM;
+		goto err_orig_busy;
 	}
 
 	crc = kmalloc_array(num_pages, sizeof(u32), GFP_KERNEL);
@@ -147,8 +156,8 @@ __igt_reset_stolen(struct intel_gt *gt,
 				      ggtt->error_capture.start,
 				      PAGE_SIZE);
 
-		busy = intel_region_ttm_range_busy(gt->i915->mm.stolen_region,
-						   PFN_PHYS(page), PAGE_SIZE);
+		busy = intel_region_ttm_range_busy_debug(gt->i915->mm.stolen_region,
+						   PFN_PHYS(page), PAGE_SIZE, &orig_busy[page]);
 		if (!busy)
 			memset_io(s, STACK_MAGIC, PAGE_SIZE);
 
@@ -183,6 +192,7 @@ __igt_reset_stolen(struct intel_gt *gt,
 		void *in;
 		u32 x;
 		bool busy;
+		struct ttm_resource_dbg dbg;
 
 		ggtt->vm.insert_page(&ggtt->vm, dma,
 				     ggtt->error_capture.start,
@@ -198,8 +208,8 @@ __igt_reset_stolen(struct intel_gt *gt,
 			in = tmp;
 		x = crc32_le(0, in, PAGE_SIZE);
 
-		busy = intel_region_ttm_range_busy(gt->i915->mm.stolen_region,
-						   PFN_PHYS(page), PAGE_SIZE);
+		busy = intel_region_ttm_range_busy_debug(gt->i915->mm.stolen_region,
+						   PFN_PHYS(page), PAGE_SIZE, &dbg);
 		if (x != crc[page] && !busy) {
 			pr_debug("unused stolen page %pa modified by GPU reset\n",
 				 &page);
@@ -209,6 +219,27 @@ __igt_reset_stolen(struct intel_gt *gt,
 				in = kmap(orig[page]);
 				igt_hexdump(in, PAGE_SIZE);
 				kunmap(orig[page]);
+				pr_debug("BOB_DEBUG: %s(): dbg.req={ start=0x%llx size=0x%llx end=0x%llx }\n",
+						__func__, dbg.req.start,
+						dbg.req.size, dbg.req.end);
+				pr_debug("BOB_DEBUG: %s(): dbg.res={ start=0x%lx num_pages=0x%lx mem_type=0x%x placement=0x%x }\n",
+						__func__, dbg.res.start,
+						dbg.res.num_pages,
+						dbg.res.mem_type,
+						dbg.res.placement);
+				pr_debug("BOB_DEBUG: %s(): orig_busy.req={ start=0x%llx size=0x%llx end=0x%llx }\n",
+						__func__, orig_busy[page].req.start,
+						orig_busy[page].req.size, orig_busy[page].req.end);
+				pr_debug("BOB_DEBUG: %s(): orig_busy.res={ start=0x%lx num_pages=0x%lx mem_type=0x%x placement=0x%x }\n",
+						__func__, orig_busy[page].res.start,
+						orig_busy[page].res.num_pages,
+						orig_busy[page].res.mem_type,
+						orig_busy[page].res.placement);
+				pr_debug("BOB_DEBUG: %s(): orig_busy.busy=%d orig_busy.err=%d\n",
+						__func__,
+						orig_busy[page].busy,
+						orig_busy[page].err);
+
 			}
 			max = page;
 		}
@@ -240,6 +271,8 @@ __igt_reset_stolen(struct intel_gt *gt,
 	kfree(crc);
 err_orig:
 	free_orig(orig, num_pages);
+err_orig_busy:
+	vfree(orig_busy);
 	return err;
 }
 
diff --git a/drivers/gpu/drm/i915/intel_region_ttm.c b/drivers/gpu/drm/i915/intel_region_ttm.c
index b3850188981b..a95aa84cdb7c 100644
--- a/drivers/gpu/drm/i915/intel_region_ttm.c
+++ b/drivers/gpu/drm/i915/intel_region_ttm.c
@@ -294,3 +294,30 @@ bool intel_region_ttm_range_busy(struct intel_memory_region *mem,
 	intel_region_ttm_resource_free(mem, dummy);
 	return false;
 }
+
+bool intel_region_ttm_range_busy_debug(struct intel_memory_region *mem,
+				 u64 start, u64 size, struct ttm_resource_dbg *dbg)
+{
+	struct ttm_resource *dummy;
+
+	dummy = intel_region_ttm_resource_alloc(mem, size, start, start + size,
+						I915_BO_ALLOC_CONTIGUOUS);
+	if (IS_ERR(dummy)) {
+		dbg->busy = true;
+		dbg->err = PTR_ERR(dummy);
+		return true;
+	}
+
+	dbg->res.start = dummy->start;
+	dbg->res.num_pages = dummy->num_pages;
+	dbg->res.mem_type = dummy->mem_type;
+	dbg->res.placement = dummy->placement;
+	dbg->req.start = start;
+	dbg->req.size = size;
+	dbg->req.end = start + size;
+	dbg->busy = false;
+	dbg->err = 0;
+
+	intel_region_ttm_resource_free(mem, dummy);
+	return false;
+}
diff --git a/drivers/gpu/drm/i915/intel_region_ttm.h b/drivers/gpu/drm/i915/intel_region_ttm.h
index 1e88472fb2ea..df6a91ddb0db 100644
--- a/drivers/gpu/drm/i915/intel_region_ttm.h
+++ b/drivers/gpu/drm/i915/intel_region_ttm.h
@@ -6,6 +6,7 @@
 #define _INTEL_REGION_TTM_H_
 
 #include <linux/types.h>
+#include <drm/ttm/ttm_resource.h>
 
 #include "i915_selftest.h"
 
@@ -31,6 +32,18 @@ void intel_region_ttm_resource_free(struct intel_memory_region *mem,
 
 bool intel_region_ttm_range_busy(struct intel_memory_region *mem,
 				 u64 start, u64 size);
+struct ttm_resource_dbg {
+	struct ttm_resource res;
+	struct {
+		u64 start;
+		u64 size;
+		u64 end;
+	} req;
+	bool busy;
+	int err;
+};
+bool intel_region_ttm_range_busy_debug(struct intel_memory_region *mem,
+				 u64 start, u64 size, struct ttm_resource_dbg *dbg);
 
 int intel_region_to_ttm_type(const struct intel_memory_region *mem);
 
-- 
2.25.1



More information about the Intel-gfx-trybot mailing list