All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: dri-devel@lists.freedesktop.org
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>, intel-gfx@lists.freedesktop.org
Subject: [PATCH 2/2] drm/selftests/mm: Add callsite indicator to common asserts
Date: Thu,  9 Nov 2017 21:24:35 +0000	[thread overview]
Message-ID: <20171109212435.9265-2-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20171109212435.9265-1-chris@chris-wilson.co.uk>

The majority of the asserts (validating nodes and ranges) are shared
amongst several subtests. This makes identification of which caller
failed hard; but we uniquely identify them if we include the callsite
into the assertion error message (a single frame stacktrace).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/selftests/test-drm_mm.c | 46 +++++++++++++++++++++++----------
 1 file changed, 32 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c
index 7cc935d7b7aa..5f1477329bee 100644
--- a/drivers/gpu/drm/selftests/test-drm_mm.c
+++ b/drivers/gpu/drm/selftests/test-drm_mm.c
@@ -59,13 +59,16 @@ static bool assert_no_holes(const struct drm_mm *mm)
 	drm_mm_for_each_hole(hole, mm, hole_start, hole_end)
 		count++;
 	if (count) {
-		pr_err("Expected to find no holes (after reserve), found %lu instead\n", count);
+		pr_err("%pS: Expected to find no holes (after reserve), found %lu instead\n",
+		       __builtin_return_address(0),
+		       count);
 		return false;
 	}
 
 	drm_mm_for_each_node(hole, mm) {
 		if (drm_mm_hole_follows(hole)) {
-			pr_err("Hole follows node, expected none!\n");
+			pr_err("%pS: Hole follows node, expected none!\n",
+			       __builtin_return_address(0));
 			return false;
 		}
 	}
@@ -87,7 +90,8 @@ static bool assert_one_hole(const struct drm_mm *mm, u64 start, u64 end)
 	drm_mm_for_each_hole(hole, mm, hole_start, hole_end) {
 		if (start != hole_start || end != hole_end) {
 			if (ok)
-				pr_err("empty mm has incorrect hole, found (%llx, %llx), expect (%llx, %llx)\n",
+				pr_err("%pS: empty mm has incorrect hole, found (%llx, %llx), expect (%llx, %llx)\n",
+				       __builtin_return_address(0),
 				       hole_start, hole_end,
 				       start, end);
 			ok = false;
@@ -95,7 +99,9 @@ static bool assert_one_hole(const struct drm_mm *mm, u64 start, u64 end)
 		count++;
 	}
 	if (count != 1) {
-		pr_err("Expected to find one hole, found %lu instead\n", count);
+		pr_err("%pS: Expected to find one hole, found %lu instead\n",
+		       __builtin_return_address(0),
+		       count);
 		ok = false;
 	}
 
@@ -108,40 +114,48 @@ static bool assert_continuous(const struct drm_mm *mm, u64 size)
 	unsigned long n;
 	u64 addr;
 
-	if (!assert_no_holes(mm))
+	if (!assert_no_holes(mm)) {
+		pr_err("%pS: expected no holes!\n",
+		       __builtin_return_address(0));
 		return false;
+	}
 
 	n = 0;
 	addr = 0;
 	drm_mm_for_each_node(node, mm) {
 		if (node->start != addr) {
-			pr_err("node[%ld] list out of order, expected %llx found %llx\n",
+			pr_err("%pS: node[%ld] list out of order, expected %llx found %llx\n",
+			       __builtin_return_address(0),
 			       n, addr, node->start);
 			return false;
 		}
 
 		if (node->size != size) {
-			pr_err("node[%ld].size incorrect, expected %llx, found %llx\n",
+			pr_err("%pS: node[%ld].size incorrect, expected %llx, found %llx\n",
+			       __builtin_return_address(0),
 			       n, size, node->size);
 			return false;
 		}
 
 		if (drm_mm_hole_follows(node)) {
-			pr_err("node[%ld] is followed by a hole!\n", n);
+			pr_err("%pS: node[%ld] is followed by a hole!\n",
+			       __builtin_return_address(0), n);
 			return false;
 		}
 
 		found = NULL;
 		drm_mm_for_each_node_in_range(check, mm, addr, addr + size) {
 			if (node != check) {
-				pr_err("lookup return wrong node, expected start %llx, found %llx\n",
+				pr_err("%pS: lookup return wrong node, expected start %llx, found %llx\n",
+				       __builtin_return_address(0),
 				       node->start, check->start);
 				return false;
 			}
 			found = check;
 		}
 		if (!found) {
-			pr_err("lookup failed for node %llx + %llx\n",
+			pr_err("%pS: lookup failed for node %llx + %llx\n",
+			       __builtin_return_address(0),
 			       addr, size);
 			return false;
 		}
@@ -170,24 +184,28 @@ static bool assert_node(struct drm_mm_node *node, struct drm_mm *mm,
 	bool ok = true;
 
 	if (!drm_mm_node_allocated(node) || node->mm != mm) {
-		pr_err("node not allocated\n");
+		pr_err("%pS: node not allocated\n",
+		       __builtin_return_address(0));
 		ok = false;
 	}
 
 	if (node->size != size) {
-		pr_err("node has wrong size, found %llu, expected %llu\n",
+		pr_err("%pS: node has wrong size, found %llu, expected %llu\n",
+		       __builtin_return_address(0),
 		       node->size, size);
 		ok = false;
 	}
 
 	if (misalignment(node, alignment)) {
-		pr_err("node is misaligned, start %llx rem %llu, expected alignment %llu\n",
+		pr_err("%pS: node is misaligned, start %llx rem %llu, expected alignment %llu\n",
+		       __builtin_return_address(0),
 		       node->start, misalignment(node, alignment), alignment);
 		ok = false;
 	}
 
 	if (node->color != color) {
-		pr_err("node has wrong color, found %lu, expected %lu\n",
+		pr_err("%pS: node has wrong color, found %lu, expected %lu\n",
+		       __builtin_return_address(0),
 		       node->color, color);
 		ok = false;
 	}
-- 
2.15.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-11-09 21:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-09 21:24 [PATCH 1/2] lib/rbtree,drm/mm: Add rbtree_replace_node_cached() Chris Wilson
2017-11-09 21:24 ` Chris Wilson [this message]
2017-11-21  8:07   ` [PATCH 2/2] drm/selftests/mm: Add callsite indicator to common asserts Joonas Lahtinen
2017-11-09 21:46 ` ✗ Fi.CI.BAT: warning for series starting with [1/2] lib/rbtree, drm/mm: Add rbtree_replace_node_cached() Patchwork
2017-11-10 14:26 ` [PATCH 1/2] " Davidlohr Bueso
2017-11-21  8:49   ` [PATCH 1/2] lib/rbtree,drm/mm: " Joonas Lahtinen
2017-11-22 10:07 ` [PATCH] " Chris Wilson
2017-11-22 10:07   ` Chris Wilson
2017-11-22 10:32 ` ✓ Fi.CI.BAT: success for series starting with lib/rbtree, drm/mm: Add rbtree_replace_node_cached() (rev2) Patchwork
2017-11-22 11:53 ` ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171109212435.9265-2-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.